# @luigi-project/plugin-auth-oauth2

> OAuth2 implicit grant provider plugin for @luigi-project/core

Latest version **2.31.0** (published 2026-06-12) · Apache-2.0 license · 2.3K weekly downloads

## Install

```sh
npm install @luigi-project/plugin-auth-oauth2
pnpm add @luigi-project/plugin-auth-oauth2
yarn add @luigi-project/plugin-auth-oauth2
bun add @luigi-project/plugin-auth-oauth2
```

## Health

**Score 50/100 (C)** — status: active.

Positive: no vulnerabilities; high maintenance score.

Warnings: no types; no esm support.

Negative: declining downloads.

## Facts

| | |
|---|---|
| Version | 2.31.0 |
| Published | 2026-06-12 |
| First published | 2020-02-26 |
| Weekly downloads | 2.3K |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 924 |
| Maintainers | hardl, luigi-robot, johannesdoberer |
| Keywords | luigi, core, oauth2, provider |

## Links

- npm: https://www.npmjs.com/package/@luigi-project/plugin-auth-oauth2
- Repository: https://github.com/luigi-project/luigi
- Homepage: https://github.com/luigi-project/luigi#readme
- Issues: https://github.com/luigi-project/luigi/issues
- npm.io page: https://npm.io/package/@luigi-project/plugin-auth-oauth2

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 2.31.0 (latest) — 2026-06-12
- 2.31.1-dev.202608240024 (next) — 2026-08-24
- 2.31.1-dev.202607310053 (luigi-plugin-auth-oauth2) — 2026-07-31
- 2.30.0 (v2-30) — 2026-06-01
- 2.29.0 (v2-29) — 2026-03-19
- 2.28.0 (v2-28) — 2026-02-26
- 2.27.0 (v2-27) — 2026-02-09
- 2.26.0 (v2-26) — 2025-12-01
- 2.25.1 (v2-25) — 2025-10-22
- 2.24.0 (v2-24) — 2025-09-18
- 2.23.1 (v2-23) — 2025-07-28
- 2.22.1 (v2-22) — 2025-05-23
- 2.21.3 (v2-21) — 2025-04-23
- 2.20.0 (v2-20) — 2025-02-19
- 2.19.2 (v2-19) — 2025-01-16
- … 1058 more at https://npm.io/package/@luigi-project/plugin-auth-oauth2/versions

## README

<!-- meta
{
  "node": {
    "label": "OAuth2 Plugin",
    "category": {
      "label": "Authorization",
      "collapsible": true
    },
    "metaData": {
      "categoryPosition": 4,
      "position": 2
    }
  }
}
meta -->

# OAuth2 - Authorization Plugin for Luigi Core

## Overview

This [authorization plugin](https://github.com/luigi-project/luigi/tree/main/plugins/auth/public/auth-oauth2) contains a library that allows your application to extend the [Luigi framework](https://github.com/luigi-project/luigi/tree/main/core) with an OAuth2 authorization provider.
Further configuration details can be found in the [main documentation](https://docs.luigi-project.io/docs/authorization-configuration#oauth2-implicit-grant-configuration).

## Installation

Install the plugin in your project using npm:
```bash
npm install @luigi-project/plugin-auth-oauth2
```

Import the plugin in places where you want to use it, depending on the environment of your choice:
```javascript
var oAuth2ImplicitGrant = require('@luigi-project/plugin-auth-oauth2');
```
or
```javascript
import oAuth2ImplicitGrant from '@luigi-project/plugin-auth-oauth2';
```

Then, integrate it as an authorization provider in your Luigi configuration file:
```javascript
Luigi.setConfig({
  auth: {
    use: 'myProviderConfig',
    myProviderConfig: {
      idpProvider: oAuth2ImplicitGrant,
      // ... configuration data comes here
      redirect_uri: '/assets/auth-oauth2/callback.html'
    }
  }
})
```

 We provide a `callback.html` file through our `plugin-auth-oauth2` package. This `callback.html` file resides in `node_modules/@luigi-project/plugin-auth-oauth2/callback.html` and needs to be copied to a folder in your Luigi Core installation, which is the return path for the IdP provider, configured through the `redirect_uri` setting. The default location of `redirect_uri` is `/assets/auth-oauth2/callback.html`.

The examples given below give some alternatives on how to copy this file in your project. However, you may choose your own way of copying the `callback.html` file to the default location depending on your environment.

For applications involving a webpack configuration, one way to copy the `callback.html` file is using packages such as [copy-webpack-plugin](https://www.npmjs.com/package/copy-webpack-plugin) and then including the following in your webpack configuration file:

```javascript
const CopyWebpackPlugin = require('copy-webpack-plugin');

{
  plugins: [
    new CopyWebpackPlugin([{
      from: 'node_modules/@luigi-project/plugin-auth-oauth2/callback.html',
      to: 'src/assets/auth-oauth2'
    }])
  ]
}
```

If your application does not use webpack or you installed Luigi without a framework, you can use any copy plugin to copy the `callback.html` file and then modify the `package.json` script to copy the file when building. One package that could be helpful is [copyfiles](https://www.npmjs.com/package/copyfiles). Following is an example:

```javascript
"buildConfig": "webpack --entry ./src/luigi-config/luigi-config.es6.js --output-path ./public/assets --output-filename luigi-config.js --mode production",
"build": "npm run buildConfig && npm run copyCallbackOAuth",
"copyCallbackOAuth": "copyfiles -f node_modules/@luigi-project/plugin-auth-oauth2/callback.html public/assets/auth-oauth2"
```

Running `npm run build` should then suffice to bundle the config and also copy the callback file.

---
_Source: https://npm.io/package/@luigi-project/plugin-auth-oauth2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
