27 |
28 |
29 | ## Overview
30 |
31 | This is the repository for the documentation page for NextAuth.js!
32 |
33 | NextAuth.js is a complete open source authentication solution for [Next.js](http://nextjs.org/) applications.
34 |
35 | This documentation site is based on the [Docusaurus](https://docusaurus.io) framework.
36 |
37 | ## Getting Started
38 |
39 | To start a local environment of this project, please do the following.
40 |
41 | 1. Clone the repository.
42 |
43 | ```bash
44 | $ git clone https://github.com/nextauthjs/docs.git
45 | ```
46 |
47 | 2. Install dependencies
48 |
49 | ```bash
50 | $ npm install
51 | ```
52 |
53 | 3. Start the development server
54 |
55 | ```bash
56 | $ npm start
57 | ```
58 |
59 | And thats all! Now you should have a local copy of this docs site running at [localhost:3000](http://localhost:3000)!
60 |
61 | ## Contributing
62 |
63 | We're open to all community contributions! If you'd like to contribute in any way, please first read our [Contributing Guide](https://github.com/nextauthjs/next-auth/blob/canary/CONTRIBUTING.md).
64 |
65 | ## License
66 |
67 | ISC
68 |
--------------------------------------------------------------------------------
/docs/adapters/fauna.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: fauna
3 | title: FaunaDB
4 | ---
5 |
6 | # FaunaDB
7 |
8 | This is the Fauna Adapter for [`next-auth`](https://next-auth.js.org). This package can only be used in conjunction with the primary `next-auth` package. It is not a standalone package.
9 |
10 | You can find the Fauna schema and seed information in the docs at [next-auth.js.org/adapters/fauna](https://next-auth.js.org/adapters/fauna).
11 |
12 | ## Getting Started
13 |
14 | 1. Install the necessary packages
15 |
16 | ```bash npm2yarn
17 | npm install next-auth @next-auth/fauna-adapter faunadb
18 | ```
19 |
20 | 2. Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.
21 |
22 | ```javascript title="pages/api/auth/[...nextauth].js"
23 | import NextAuth from "next-auth"
24 | import { Client as FaunaClient } from "faunadb"
25 | import { FaunaAdapter } from "@next-auth/fauna-adapter"
26 |
27 | const client = new FaunaClient({
28 | secret: "secret",
29 | scheme: "http",
30 | domain: "localhost",
31 | port: 8443,
32 | })
33 |
34 | // For more information on each option (and a full list of options) go to
35 | // https://next-auth.js.org/configuration/options
36 | export default NextAuth({
37 | // https://next-auth.js.org/providers/overview
38 | providers: [],
39 | adapter: FaunaAdapter(client)
40 | ...
41 | })
42 | ```
43 |
44 | ## Schema
45 |
46 | Run the following commands inside of the `Shell` tab in the Fauna dashboard to setup the appropriate collections and indexes.
47 |
48 | ```javascript
49 | CreateCollection({ name: "accounts" })
50 | CreateCollection({ name: "sessions" })
51 | CreateCollection({ name: "users" })
52 | CreateCollection({ name: "verification_tokens" })
53 | CreateIndex({
54 | name: "account_by_provider_and_provider_account_id",
55 | source: Collection("accounts"),
56 | unique: true,
57 | terms: [
58 | { field: ["data", "provider"] },
59 | { field: ["data", "providerAccountId"] },
60 | ],
61 | })
62 | CreateIndex({
63 | name: "session_by_session_token",
64 | source: Collection("sessions"),
65 | unique: true,
66 | terms: [{ field: ["data", "sessionToken"] }],
67 | })
68 | CreateIndex({
69 | name: "user_by_email",
70 | source: Collection("users"),
71 | unique: true,
72 | terms: [{ field: ["data", "email"] }],
73 | })
74 | CreateIndex({
75 | name: "verification_token_by_identifier_and_token",
76 | source: Collection("verification_tokens"),
77 | unique: true,
78 | terms: [{ field: ["data", "identifier"] }, { field: ["data", "token"] }],
79 | })
80 | ```
81 |
--------------------------------------------------------------------------------
/docs/adapters/mongodb.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: mongodb
3 | title: MongoDB
4 | ---
5 |
6 | # MongoDB
7 |
8 | The MongoDB adapter does not handle connections automatically, so you will have to make sure that you pass the Adapter a `MongoClient` that is connected already. Below you can see an example how to do this.
9 |
10 | ## Usage
11 |
12 | 1. Install the necessary packages
13 |
14 | ```bash npm2yarn
15 | npm install next-auth @next-auth/mongodb-adapter mongodb
16 | ```
17 |
18 | 2. Add `lib/mongodb.js`
19 |
20 | ```js
21 | // This approach is taken from https://github.com/vercel/next.js/tree/canary/examples/with-mongodb
22 | import { MongoClient } from "mongodb"
23 |
24 | const uri = process.env.MONGODB_URI
25 | const options = {
26 | useUnifiedTopology: true,
27 | useNewUrlParser: true,
28 | }
29 |
30 | let client
31 | let clientPromise
32 |
33 | if (!process.env.MONGODB_URI) {
34 | throw new Error("Please add your Mongo URI to .env.local")
35 | }
36 |
37 | if (process.env.NODE_ENV === "development") {
38 | // In development mode, use a global variable so that the value
39 | // is preserved across module reloads caused by HMR (Hot Module Replacement).
40 | if (!global._mongoClientPromise) {
41 | client = new MongoClient(uri, options)
42 | global._mongoClientPromise = client.connect()
43 | }
44 | clientPromise = global._mongoClientPromise
45 | } else {
46 | // In production mode, it's best to not use a global variable.
47 | client = new MongoClient(uri, options)
48 | clientPromise = client.connect()
49 | }
50 |
51 | // Export a module-scoped MongoClient promise. By doing this in a
52 | // separate module, the client can be shared across functions.
53 | export default clientPromise
54 | ```
55 |
56 | 3. Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.
57 |
58 | ```js
59 | import NextAuth from "next-auth"
60 | import { MongoDBAdapter } from "@next-auth/mongodb-adapter"
61 | import clientPromise from "lib/mongodb"
62 |
63 | // For more information on each option (and a full list of options) go to
64 | // https://next-auth.js.org/configuration/options
65 | export default NextAuth({
66 | adapter: MongoDBAdapter(clientPromise),
67 | ...
68 | })
69 | ```
70 |
--------------------------------------------------------------------------------
/docs/adapters/overview.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: overview
3 | title: Overview
4 | ---
5 |
6 | An **Adapter** in NextAuth.js connects your application to whatever database or backend system you want to use to store data for users, their accounts, sessions, etc. Adapters are optional, unless you need to persist user information in your own database, or you want to implement certain flows. The [Email Provider](/providers/email) requires an adapter to be able to save [Verification Tokens](/adapters/models#verification-token).
7 |
8 | :::tip
9 | When using a database, you can still use JWT for session handling for fast access. See the [`session.jwt`](/configuration/options#session) option. Read about the trade-offs of JWT in the [FAQ](/faq#json-web-tokens).
10 | :::
11 |
12 | We have a list of official adapters that are distributed as their own packages under the `@next-auth/{name}-adapter` namespace. Their source code is available in the organization repository at [`nextauthjs/adapters`](https://github.com/nextauthjs/adapters). Any issues regarding these adapters should be opened on that repository.
13 |
14 | - [`prisma`](./prisma)
15 | - [`fauna`](./fauna)
16 | - [`dynamodb`](./dynamodb)
17 | - [`firebase`](./firebase)
18 | - [`pouchdb`](./pouchdb)
19 | - [`mongodb`](./mongodb)
20 | - [`neo4j`](./neo4j)
21 | - [`typeorm-legacy`](./typeorm)
22 | - [`sequelize`](./sequelize)
23 | - [`dgraph`](./dgraph)
24 |
25 | ## Custom Adapter
26 |
27 | If you have a database/backend that we don't officially support, you can create your own adapter.
28 | See the tutorial for [creating a database Adapter](/tutorials/creating-a-database-adapter) for more information.
29 |
30 | :::tip
31 | If you would like to see a new adapter in the official repository, please [open a PR](https://github.com/nextauthjs/adapters) and we will help you to get it merged. Tell us if you are interested in becoming a one of the maintainers of any of the official adapters.
32 | :::
33 |
34 | ### Editor integration
35 |
36 | Adapters are strongly typed, and they rely on the single `Adapter` interface imported from `next-auth/adapters`.
37 |
38 | When writing your own custom Adapter in plain JavaScript, note that you can use **JSDoc** to get helpful editor hints and auto-completion like so:
39 |
40 | ```js
41 | /** @return { import("next-auth/adapters").Adapter } */
42 | function MyAdapter() {
43 | return {
44 | // your adapter methods here
45 | }
46 | }
47 | ```
48 |
49 | :::note
50 | This will work in code editors with a strong TypeScript integration like VSCode or WebStorm. It might not work if you're using more lightweight editors like VIM or Atom.
51 | :::
52 |
--------------------------------------------------------------------------------
/docs/adapters/pouchdb.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: pouchdb
3 | title: PouchDB
4 | ---
5 |
6 | # PouchDB
7 |
8 | This is the PouchDB Adapter for [`next-auth`](https://next-auth.js.org). This package can only be used in conjunction with the primary `next-auth` package. It is not a standalone package.
9 |
10 | Depending on your architecture you can use PouchDB's http adapter to reach any database compliant with the CouchDB protocol (CouchDB, Cloudant, ...) or use any other PouchDB compatible adapter (leveldb, in-memory, ...)
11 |
12 | ## Getting Started
13 |
14 | > **Prerequisites**: Your PouchDB instance MUST provide the `pouchdb-find` plugin since it is used internally by the adapter to build and manage indexes
15 |
16 | 1. Install `next-auth` and `@next-auth/pouchdb-adapter`
17 |
18 | ```bash npm2yarn
19 | npm install next-auth @next-auth/pouchdb-adapter
20 | ```
21 |
22 | 2. Add this adapter to your `pages/api/auth/[...nextauth].js` next-auth configuration object
23 |
24 | ```javascript title="pages/api/auth/[...nextauth].js"
25 | import NextAuth from "next-auth"
26 | import GoogleProvider from "next-auth/providers/google"
27 | import { PouchDBAdapter } from "@next-auth/pouchdb-adapter"
28 | import PouchDB from "pouchdb"
29 |
30 | // Setup your PouchDB instance and database
31 | PouchDB.plugin(require("pouchdb-adapter-leveldb")) // Any other adapter
32 | .plugin(require("pouchdb-find")) // Don't forget the `pouchdb-find` plugin
33 |
34 | const pouchdb = new PouchDB("auth_db", { adapter: "leveldb" })
35 |
36 | // For more information on each option (and a full list of options) go to
37 | // https://next-auth.js.org/configuration/options
38 | export default NextAuth({
39 | // https://next-auth.js.org/providers/overview
40 | providers: [
41 | GoogleProvider({
42 | clientId: process.env.GOOGLE_ID,
43 | clientSecret: process.env.GOOGLE_SECRET,
44 | }),
45 | ],
46 | adapter: PouchDBAdapter(pouchdb),
47 | // ...
48 | })
49 | ```
50 |
51 | ## Advanced
52 |
53 | ### Memory-First Caching Strategy
54 |
55 | If you need to boost your authentication layer performance, you may use PouchDB's powerful sync features and various adapters, to build a memory-first caching strategy.
56 |
57 | Use an in-memory PouchDB as your main authentication database, and synchronize it with any other persisted PouchDB. You may do a one way, one-off replication at startup from the persisted PouchDB into the in-memory PouchDB, then two-way, continuous, retriable sync.
58 |
59 | This will most likely not increase performance much in a serverless environment due to various reasons such as concurrency, function startup time increases, etc.
60 |
61 | For more details, please see https://pouchdb.com/api.html#sync
62 |
--------------------------------------------------------------------------------
/docs/configuration/databases.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: databases
3 | title: Databases
4 | ---
5 |
6 | NextAuth.js offers multiple database adapters. Check out [the overview](/adapters/overview).
7 |
8 | > As of **v4** NextAuth.js no longer ships with an adapter included by default. If you would like to persist any information, you need to install one of the many available adapters yourself. See the individual adapter documentation pages for more details.
9 |
10 | To learn more about databases in NextAuth.js and how they are used, check out [databases in the FAQ](/faq#databases).
11 |
12 | ---
13 |
14 | ## How to use a database
15 |
16 | See the [documentation for adapters](/adapters/overview) for more information on advanced configuration, including how to use NextAuth.js with other databases using a [custom adapter](/tutorials/creating-a-database-adapter).
17 |
--------------------------------------------------------------------------------
/docs/configuration/events.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: events
3 | title: Events
4 | ---
5 |
6 | Events are asynchronous functions that do not return a response, they are useful for audit logs / reporting or handling any other side-effects.
7 |
8 | You can specify a handler for any of these events below, for debugging or for an audit log.
9 |
10 | :::note
11 | The execution of your authentication API will be blocked by an `await` on your event handler. If your event handler starts any burdensome work it should not block its own promise on that work.
12 | :::
13 |
14 | ## Events
15 |
16 | ### signIn
17 |
18 | Sent on successful sign in.
19 |
20 | The message will be an object and contain:
21 |
22 | - `user` (from your adapter or from the provider if a `credentials` type provider)
23 | - `account` (from your adapter or the provider)
24 | - `profile` (from the provider, is `undefined` on `credentials` provider, use `user` instead)
25 | - `isNewUser` (whether your adapter had a user for this account already)
26 |
27 | ### signOut
28 |
29 | Sent when the user signs out.
30 |
31 | The message object will contain one of these depending on if you use JWT or database persisted sessions:
32 |
33 | - `token`: The JWT token for this session.
34 | - `session`: The session object from your adapter that is being ended
35 |
36 | ### createUser
37 |
38 | Sent when the adapter is told to create a new user.
39 |
40 | The message object will contain the user.
41 |
42 | ### updateUser
43 |
44 | Sent when the adapter is told to update an existing user. Currently this is only sent when the user verifies their email address.
45 |
46 | The message object will contain the user.
47 |
48 | ### linkAccount
49 |
50 | Sent when an account in a given provider is linked to a user in our user database. For example, when a user signs up with Twitter or when an existing user links their Google account.
51 |
52 | The message object will contain:
53 |
54 | - `user`: The user object from your adapter.
55 | - `providerAccount`: The object returned from the provider.
56 |
57 | ### session
58 |
59 | Sent at the end of a request for the current session.
60 |
61 | The message object will contain one of these depending on if you use JWT or database persisted sessions:
62 |
63 | - `token`: The JWT token for this session.
64 | - `session`: The session object from your adapter.
65 |
--------------------------------------------------------------------------------
/docs/configuration/providers/email.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: email
3 | title: Email
4 | ---
5 |
6 | ### How to
7 |
8 | The Email provider sends "magic links" via email that the user can click on to sign in.
9 | You have likely seen them before if you have used software like Slack.
10 |
11 | Adding support for signing in via email in addition to one or more OAuth services provides a way for users to sign in if they lose access to their OAuth account (e.g. if it is locked or deleted).
12 |
13 | Configuration is similar to other providers, but the options are different:
14 |
15 | ```js title="pages/api/auth/[...nextauth].js"
16 | import EmailProvider from `next-auth/providers/email`
17 | ...
18 | providers: [
19 | EmailProvider({
20 | server: process.env.EMAIL_SERVER,
21 | from: process.env.EMAIL_FROM,
22 | // maxAge: 24 * 60 * 60, // How long email links are valid for (default 24h)
23 | }),
24 | ],
25 | ...
26 | ```
27 |
28 | See the [Email provider documentation](/providers/email) for more information on how to configure email sign in.
29 |
30 | :::note
31 | The email provider requires a database, it cannot be used without one.
32 | :::
33 |
34 | ### Options
35 |
36 | | Name | Description | Type | Required |
37 | | :---------------------: | :---------------------------------------------------------------------------------: | :------------------------------: | :------: |
38 | | id | Unique ID for the provider | `string` | Yes |
39 | | name | Descriptive name for the provider | `string` | Yes |
40 | | type | Type of provider, in this case `email` | `"email"` | Yes |
41 | | server | Path or object pointing to the email server | `string` or `Object` | Yes |
42 | | sendVerificationRequest | Callback to execute when a verification request is sent | `(params) => Promise` | Yes |
43 | | from | The email address from which emails are sent, default: "" | `string` | No |
44 | | maxAge | How long until the e-mail can be used to log the user in seconds. Defaults to 1 day | `number` | No |
45 |
--------------------------------------------------------------------------------
/docs/contributors.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: contributors
3 | title: Contributors
4 | ---
5 |
6 | ## Core Team
7 |
8 | * [Iain Collins](https://github.com/iaincollins)
9 | * [Balázs Orbán](https://github.com/sponsors/balazsorban44)
10 | * [Nico Domino](https://github.com/ndom91)
11 | * [Lluis Agusti](https://github.com/lluia)
12 | * [Lori Karikari](https://github.com/LoriKarikari)
13 | * [Fredrik Pettersen](https://github.com/Fumler)
14 | * [Gerald Nolan](https://github.com/geraldnolan)
15 | * [Jefferson Bledsoe](https://github.com/JeffersonBledsoe)
16 |
17 | _Special thanks to Balazs Orban for acting as core maintainer throughout most of the v3 and v4 lifecycle of NextAuth! Also to Lori Karikari for creating most of the original provider configurations, to Nico Domino for creating and maintaining this documentation site and other core contributions, to Lluis Agusti for many core contributions especially involving TypeScript, to Fredrik Pettersen for creating the original Prisma adapter, to Gerald Nolan for adding support for Sign in with Apple, ._
18 |
19 | ## Other Contributors
20 |
21 | NextAuth.js as it exists today has been possible thanks to the work of many individual contributors.
22 |
23 | Thank you to the [dozens of individual contributors](https://github.com/nextauthjs/next-auth/graphs/contributors) who have help shaped NextAuth.js.
24 |
25 | ## OpenCollective
26 |
27 | You can find NextAuth.js on OpenCollective. We are very thankful for all of our existing contributors and would be delighted if you or your company would decide to join them.
28 |
29 | More information can be found at: https://opencollective.com/nextauth
30 |
31 | ## History
32 |
33 | NextAuth.js was originally developed by Iain Collins in 2016.
34 |
35 | In 2020, NextAuth.js was rebuilt from the ground up to support Serverless, with support for MySQL, Postgres and MongoDB, JSON Web Tokens and built in support for over a dozen authentication providers.
36 |
--------------------------------------------------------------------------------
/docs/providers/42.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: 42-school
3 | title: 42 School
4 | ---
5 |
6 | :::note
7 | 42 returns a field on `Account` called `created_at` which is a number. See the [docs](https://api.intra.42.fr/apidoc/guides/getting_started#make-basic-requests). Make sure to add this field to your database schema, in case if you are using an [Adapter](/adapters/overview).
8 | :::
9 |
10 | ## Documentation
11 |
12 | https://api.intra.42.fr/apidoc/guides/web_application_flow
13 |
14 | ## Configuration
15 |
16 | https://profile.intra.42.fr/oauth/applications/new
17 |
18 | ## Options
19 |
20 | The **42 School Provider** comes with a set of default options:
21 |
22 | - [42 School Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/42.ts)
23 |
24 | You can override any of the options to suit your own use case.
25 |
26 | ## Example
27 |
28 | ```js
29 | import FortyTwoProvider from `next-auth/providers/42`
30 | ...
31 | providers: [
32 | FortyTwoProvider({
33 | clientId: process.env.FORTY_TWO_CLIENT_ID,
34 | clientSecret: process.env.FORTY_TWO_CLIENT_SECRET
35 | })
36 | ]
37 | ...
38 | ```
39 |
--------------------------------------------------------------------------------
/docs/providers/atlassian.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: atlassian
3 | title: Atlassian
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developer.atlassian.com/cloud/jira/platform/oauth-2-authorization-code-grants-3lo-for-apps/#implementing-oauth-2-0--3lo-
9 |
10 | ## Options
11 |
12 | The **Atlassian Provider** comes with a set of default options:
13 |
14 | - [Atlassian Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/atlassian.ts)
15 |
16 | You can override any of the options to suit your own use case.
17 |
18 | ## Example
19 |
20 | ```js
21 | import AtlassianProvider from `next-auth/providers/atlassian`
22 | ...
23 | providers: [
24 | AtlassianProvider({
25 | clientId: process.env.ATLASSIAN_CLIENT_ID,
26 | clientSecret: process.env.ATLASSIAN_CLIENT_SECRET,
27 | scope: 'write:jira-work read:jira-work read:jira-user offline_access read:me'
28 | })
29 | ]
30 | ...
31 | ```
32 |
33 | ## Instructions
34 |
35 | ### Configuration
36 |
37 | :::tip
38 | An app can be created at https://developer.atlassian.com/apps/
39 | :::
40 |
41 | Under "Apis and features" in the side menu, configure the following for "OAuth 2.0 (3LO)":
42 |
43 | - Redirect URL
44 | - http://localhost:3000/api/auth/callback/atlassian
45 |
46 | :::warning
47 | To enable access to Jira Platform REST API you must enable User Identity API and add `read:me` to your provider scope option.
48 | :::
49 |
--------------------------------------------------------------------------------
/docs/providers/auth0.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: auth0
3 | title: Auth0
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://auth0.com/docs/api/authentication#authorize-application
9 |
10 | ## Configuration
11 |
12 | https://manage.auth0.com/dashboard
13 |
14 | :::tip
15 | Configure your application in Auth0 as a 'Regular Web Application' (not a 'Single Page App').
16 | :::
17 |
18 | ## Options
19 |
20 | The **Auth0 Provider** comes with a set of default options:
21 |
22 | - [Auth0 Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/auth0.ts)
23 |
24 | You can override any of the options to suit your own use case.
25 |
26 | ## Example
27 |
28 | ```js
29 | import Auth0Provider from "next-auth/providers/auth0"
30 | ...
31 | providers: [
32 | Auth0Provider({
33 | clientId: process.env.AUTH0_CLIENT_ID,
34 | clientSecret: process.env.AUTH0_CLIENT_SECRET,
35 | issuer: process.env.AUTH0_ISSUER
36 | })
37 | ]
38 | ...
39 | ```
40 |
41 | :::note
42 | `issuer` should be the fully qualified URL – e.g. `https://dev-s6clz2lv.eu.auth0.com`
43 | :::
44 |
--------------------------------------------------------------------------------
/docs/providers/azure-ad.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: azure-ad
3 | title: Azure Active Directory
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
9 |
10 | ## Configuration
11 |
12 | https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app
13 |
14 | ## Example
15 |
16 | ### To allow specific Active Directory users access:
17 |
18 | - In https://portal.azure.com/ search for "Azure Active Directory", and select your organization.
19 | - Next, go to "App Registration" in the left menu, and create a new one.
20 | - Pay close attention to "Who can use this application or access this API?"
21 | - This allows you to scope access to specific types of user accounts
22 | - Only your tenant, all azure tenants, or all azure tenants and public Microsoft accounts (Skype, Xbox, Outlook.com, etc.)
23 | - When asked for a redirection URL, use `https://yourapplication.com/api/auth/callback/azure-ad` or for development `http://localhost:3000/api/auth/callback/azure-ad`.
24 | - After your App Registration is created, under "Client Credential" create your Client secret.
25 | - Now copy your:
26 | - Application (client) ID
27 | - Directory (tenant) ID
28 | - Client secret (value)
29 |
30 | In `.env.local` create the following entries:
31 |
32 | ```
33 | AZURE_AD_CLIENT_ID=
34 | AZURE_AD_CLIENT_SECRET=
35 | AZURE_AD_TENANT_ID=
36 | ```
37 |
38 | That will default the tenant to use the `common` authorization endpoint. [For more details see here](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols#endpoints).
39 |
40 | :::note
41 | Azure AD returns the profile picture in an ArrayBuffer, instead of just a URL to the image, so our provider converts it to a base64 encoded image string and returns that instead. See: https://docs.microsoft.com/en-us/graph/api/profilephoto-get?view=graph-rest-1.0#examples. The default image size is 64x64 to avoid [running out of space](https://next-auth.js.org/faq#:~:text=What%20are%20the%20disadvantages%20of%20JSON%20Web%20Tokens%3F) in case the session is saved as a JWT.
42 | :::
43 |
44 | In `pages/api/auth/[...nextauth].js` find or add the `AzureAD` entries:
45 |
46 | ```js
47 | import AzureADProvider from 'next-auth/providers/azure-ad';
48 |
49 | ...
50 | providers: [
51 | AzureADProvider({
52 | clientId: process.env.AZURE_AD_CLIENT_ID,
53 | clientSecret: process.env.AZURE_AD_CLIENT_SECRET,
54 | tenantId: process.env.AZURE_AD_TENANT_ID,
55 | }),
56 | ]
57 | ...
58 |
59 | ```
60 |
--------------------------------------------------------------------------------
/docs/providers/battlenet.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: battle.net
3 | title: Battle.net
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://develop.battle.net/documentation/guides/using-oauth
9 |
10 | ## Configuration
11 |
12 | https://develop.battle.net/access/clients
13 |
14 | ## Options
15 |
16 | The **Battle.net Provider** comes with a set of default options:
17 |
18 | - [Battle.net Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/battlenet.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import BattleNetProvider from `next-auth/providers/battlenet`
26 | ...
27 | providers: [
28 | BattleNetProvider({
29 | clientId: process.env.BATTLENET_CLIENT_ID,
30 | clientSecret: process.env.BATTLENET_CLIENT_SECRET,
31 | region: process.env.BATTLENET_REGION
32 | })
33 | ]
34 | ...
35 | ```
36 |
--------------------------------------------------------------------------------
/docs/providers/box.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: box
3 | title: Box
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developer.box.com/reference/
9 |
10 | ## Configuration
11 |
12 | https://developer.box.com/guides/sso-identities-and-app-users/connect-okta-to-app-users/configure-box/
13 |
14 | ## Options
15 |
16 | The **Box Provider** comes with a set of default options:
17 |
18 | - [Box Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/box.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import BoxProvider from `next-auth/providers/box`
26 | ...
27 | providers: [
28 | BoxProvider({
29 | clientId: process.env.BOX_CLIENT_ID,
30 | clientSecret: process.env.BOX_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/docs/providers/cognito.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: cognito
3 | title: Amazon Cognito
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-userpools-server-contract-reference.html
9 |
10 | ## Configuration
11 |
12 | https://console.aws.amazon.com/cognito/users/
13 |
14 | You need to select your AWS region to go the the Cognito dashboard.
15 |
16 | ## Options
17 |
18 | The **Amazon Cognito Provider** comes with a set of default options:
19 |
20 | - [Amazon Cognito Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/cognito.ts)
21 |
22 | You can override any of the options to suit your own use case.
23 |
24 | ## Example
25 |
26 | ```js
27 | import CognitoProvider from `next-auth/providers/cognito`
28 | ...
29 | providers: [
30 | CognitoProvider({
31 | clientId: process.env.COGNITO_CLIENT_ID,
32 | clientSecret: process.env.COGNITO_CLIENT_SECRET,
33 | issuer: process.env.COGNITO_ISSUER,
34 | })
35 | ]
36 | ...
37 | ```
38 |
39 | :::tip
40 | The issuer is a URL, that looks like this: `https://cognito-idp.{region}.amazonaws.com/{PoolId}`
41 | :::
42 |
43 | `PoolId` is from `General Settings` in Cognito, not to be confused with the App Client ID.
44 |
45 | :::warning
46 | Make sure you select all the appropriate client settings or the OAuth flow will not work.
47 | :::
48 |
49 | 
50 |
--------------------------------------------------------------------------------
/docs/providers/coinbase.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: coinbase
3 | title: Coinbase
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.coinbase.com/api/v2
9 |
10 | ## Configuration
11 |
12 | https://www.coinbase.com/settings/api
13 |
14 | ## Options
15 |
16 | The **Coinbase Provider** comes with a set of default options:
17 |
18 | - [Coinbase Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/coinbase.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import CoinbaseProvider from `next-auth/providers/coinbase`
26 | ...
27 | providers: [
28 | CoinbaseProvider({
29 | clientId: process.env.COINBASE_CLIENT_ID,
30 | clientSecret: process.env.COINBASE_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | :::tip
37 | This Provider template has a 2 hour access token to it. A refresh token is also returned.
38 | :::
39 |
--------------------------------------------------------------------------------
/docs/providers/discord.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: discord
3 | title: Discord
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://discord.com/developers/docs/topics/oauth2
9 |
10 | ## Configuration
11 |
12 | https://discord.com/developers/applications
13 |
14 | ## Options
15 |
16 | The **Discord Provider** comes with a set of default options:
17 |
18 | - [Discord Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/discord.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import DiscordProvider from `next-auth/providers/discord`
26 | ...
27 | providers: [
28 | DiscordProvider({
29 | clientId: process.env.DISCORD_CLIENT_ID,
30 | clientSecret: process.env.DISCORD_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/docs/providers/dropbox.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: dropbox
3 | title: Dropbox
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.dropbox.com/oauth-guide
9 |
10 | ## Configuration
11 |
12 | https://www.dropbox.com/developers/apps
13 |
14 | ## Options
15 |
16 | The **Dropbox Provider** comes with a set of default options:
17 |
18 | - [Dropbox Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/dropbox.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import DropboxProvider from `next-auth/providers/dropbox`
26 | ...
27 | providers: [
28 | DropboxProvider({
29 | clientId: process.env.DROPBOX_CLIENT_ID,
30 | clientSecret: process.env.DROPBOX_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/docs/providers/eveonline.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: eveonline
3 | title: EVE Online
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.eveonline.com/blog/article/sso-to-authenticated-calls
9 |
10 | ## Configuration
11 |
12 | https://developers.eveonline.com/
13 |
14 | ## Options
15 |
16 | The **EVE Online Provider** comes with a set of default options:
17 |
18 | - [EVE Online Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/eveonline.ts)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import EVEOnlineProvider from `next-auth/providers/eveonline`
26 | ...
27 | providers: [
28 | EVEOnlineProvider({
29 | clientId: process.env.EVE_CLIENT_ID,
30 | clientSecret: process.env.EVE_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | :::tip When creating your application, make sure to select `Authentication Only` as the connection type.
37 |
38 | :::tip If using JWT for the session, you can add the `CharacterID` to the JWT token and session. Example:
39 |
40 | ```js
41 | ...
42 | options: {
43 | jwt: {
44 | secret: process.env.JWT_SECRET,
45 | },
46 | callbacks: {
47 | session: async ({ session, token }) => {
48 | session.user.id = token.id;
49 | return session;
50 | }
51 | }
52 | }
53 | ...
54 | ```
55 |
--------------------------------------------------------------------------------
/docs/providers/facebook.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: facebook
3 | title: Facebook
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/
9 |
10 | ## Configuration
11 |
12 | https://developers.facebook.com/apps/
13 |
14 | ## Options
15 |
16 | The **Facebook Provider** comes with a set of default options:
17 |
18 | - [Facebook Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/facebook.ts)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import FacebookProvider from `next-auth/providers/facebook`
26 | ...
27 | providers: [
28 | FacebookProvider({
29 | clientId: process.env.FACEBOOK_CLIENT_ID,
30 | clientSecret: process.env.FACEBOOK_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | :::tip
37 | Production applications cannot use localhost URLs to sign in with Facebook. You need to use a dedicated development application in Facebook to use **localhost** callback URLs.
38 | :::
39 |
40 | :::tip
41 | Email address may not be returned for accounts created on mobile.
42 | :::
43 |
--------------------------------------------------------------------------------
/docs/providers/faceit.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: faceit
3 | title: FACEIT
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://cdn.faceit.com/third_party/docs/FACEIT_Connect_3.0.pdf
9 |
10 | ## Configuration
11 |
12 | https://developers.faceit.com/apps
13 |
14 | Grant type: `Authorization Code`
15 |
16 | Scopes to have basic infos (email, nickname, guid and avatar) : `openid`, `email`, `profile`
17 |
18 | ## Options
19 |
20 | The **FACEIT Provider** comes with a set of default options:
21 |
22 | - [FACEIT Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/faceit.js)
23 |
24 | You can override any of the options to suit your own use case.
25 |
26 | ## Example
27 |
28 | ```js
29 | import FaceItProvider from `next-auth/providers/faceit`
30 | ...
31 | providers: [
32 | FaceItProvider({
33 | clientId: process.env.FACEIT_CLIENT_ID,
34 | clientSecret: process.env.FACEIT_CLIENT_SECRET
35 | })
36 | ]
37 | ...
38 | ```
39 |
--------------------------------------------------------------------------------
/docs/providers/foursquare.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: foursquare
3 | title: Foursquare
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developer.foursquare.com/docs/places-api/authentication/#web-applications
9 |
10 | ## Configuration
11 |
12 | https://developer.foursquare.com/
13 |
14 | :::warning
15 | Foursquare requires an additional `apiVersion` parameter in [`YYYYMMDD` format](https://developer.foursquare.com/docs/places-api/versioning/), which essentially states "I'm prepared for API changes up to this date".
16 | :::
17 |
18 | ## Options
19 |
20 | The **Foursquare Provider** comes with a set of default options:
21 |
22 | - [Foursquare Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/foursquare.js)
23 |
24 | You can override any of the options to suit your own use case.
25 |
26 | ## Example
27 |
28 | ```js
29 | import FourSquareProvider from `next-auth/providers/foursquare`
30 | ...
31 | providers: [
32 | FourSquareProvider({
33 | clientId: process.env.FOURSQUARE_CLIENT_ID,
34 | clientSecret: process.env.FOURSQUARE_CLIENT_SECRET,
35 | apiVersion: 'YYYYMMDD'
36 | })
37 | ]
38 | ...
39 | ```
40 |
--------------------------------------------------------------------------------
/docs/providers/freshbooks.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: freshbooks
3 | title: Freshbooks
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://www.freshbooks.com/api/authenticating-with-oauth-2-0-on-the-new-freshbooks-api
9 |
10 | ## Configuration
11 |
12 | https://my.freshbooks.com/#/developer
13 |
14 | ## Options
15 |
16 | The Freshbooks Provider comes with a set of default options:
17 |
18 | https://www.freshbooks.com/api/start
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import FreshbooksProvider from `next-auth/providers/freshbooks`
26 | ...
27 | providers: [
28 | FreshbooksProvider({
29 | clientId: process.env.FRESHBOOKS_CLIENT_ID,
30 | clientSecret: process.env.FRESHBOOKS_CLIENT_SECRET,
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/docs/providers/fusionauth.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: fusionauth
3 | title: FusionAuth
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://fusionauth.io/docs/v1/tech/oauth/
9 |
10 | ## Options
11 |
12 | The **FusionAuth Provider** comes with a set of default options:
13 |
14 | - [FusionAuth Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/fusionauth.ts)
15 |
16 | You can override any of the options to suit your own use case.
17 |
18 | ## Example
19 |
20 | ```js
21 | import FusionAuthProvider from `next-auth/providers/fusionauth`
22 | ...
23 | providers: [
24 | FusionAuthProvider({
25 | id: "fusionauth",
26 | name: "FusionAuth",
27 | issuer: process.env.FUSIONAUTH_ISSUER,
28 | clientId: process.env.FUSIONAUTH_CLIENT_ID,
29 | clientSecret: process.env.FUSIONAUTH_SECRET,
30 | tenantId: process.env.FUSIONAUTH_TENANT_ID // Only required if you're using multi-tenancy
31 | }),
32 | ]
33 | ...
34 | ```
35 |
36 | :::warning
37 | If you're using multi-tenancy, you need to pass in the `tenantId` option to apply the proper theme.
38 | :::
39 |
40 | ## Instructions
41 |
42 | ### Configuration
43 |
44 | :::tip
45 | An application can be created at https://your-fusionauth-server-url/admin/application.
46 |
47 | For more information, follow the [FusionAuth 5-minute setup guide](https://fusionauth.io/docs/v1/tech/5-minute-setup-guide).
48 | :::
49 |
50 | In the OAuth settings for your application, configure the following.
51 |
52 | - Redirect URL
53 | - https://localhost:3000/api/auth/callback/fusionauth
54 | - Enabled grants
55 | - Make sure _Authorization Code_ is enabled.
56 |
57 | If using JSON Web Tokens, you need to make sure the signing algorithm is RS256, you can create an RS256 key pair by
58 | going to Settings, Key Master, generate RSA and choosing SHA-256 as algorithm. After that, go to the JWT settings of
59 | your application and select this key as Access Token signing key and Id Token signing key.
60 |
--------------------------------------------------------------------------------
/docs/providers/github.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: github
3 | title: GitHub
4 | ---
5 |
6 | :::note
7 | GitHub returns a field on `Account` called `refresh_token_expires_in` which is a number. See their [docs](https://docs.github.com/en/developers/apps/building-github-apps/refreshing-user-to-server-access-tokens#response). Remember to add this field to your database schema, in case if you are using an [Adapter](/adapters/overview).
8 | :::
9 |
10 |
11 | ## Documentation
12 |
13 | https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps
14 |
15 | ## Configuration
16 |
17 | https://github.com/settings/apps
18 |
19 | ## Options
20 |
21 | The **GitHub Provider** comes with a set of default options:
22 |
23 | - [GitHub Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/github.js)
24 |
25 | You can override any of the options to suit your own use case.
26 |
27 | ## Example
28 |
29 | ```js
30 | import GitHubProvider from `next-auth/providers/github`
31 | ...
32 | providers: [
33 | GitHubProvider({
34 | clientId: process.env.GITHUB_CLIENT_ID,
35 | clientSecret: process.env.GITHUB_CLIENT_SECRET
36 | })
37 | ]
38 | ...
39 | ```
40 |
41 | :::warning
42 | Only allows one callback URL per Client ID / Client Secret.
43 | :::
44 |
45 | :::tip
46 | Email address is always returned, even if the user doesn't have a public email address on their profile.
47 | :::
48 |
--------------------------------------------------------------------------------
/docs/providers/gitlab.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: gitlab
3 | title: GitLab
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://docs.gitlab.com/ee/api/oauth2.html
9 |
10 | ## Configuration
11 |
12 | https://gitlab.com/-/profile/applications
13 |
14 | ## Options
15 |
16 | The **Gitlab Provider** comes with a set of default options:
17 |
18 | - [Gitlab Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/gitlab.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import GitlabProvider from `next-auth/providers/gitlab`
26 | ...
27 | providers: [
28 | GitlabProvider({
29 | clientId: process.env.GITLAB_CLIENT_ID,
30 | clientSecret: process.env.GITLAB_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | :::tip
37 | Enable the _"read_user"_ option in scope if you want to save the users email address on sign up.
38 | :::
39 |
--------------------------------------------------------------------------------
/docs/providers/google.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: google
3 | title: Google
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.google.com/identity/protocols/oauth2
9 |
10 | ## Configuration
11 |
12 | https://console.developers.google.com/apis/credentials
13 |
14 | ## Options
15 |
16 | The **Google Provider** comes with a set of default options:
17 |
18 | - [Google Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/google.ts)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import GoogleProvider from `next-auth/providers/google`
26 | ...
27 | providers: [
28 | GoogleProvider({
29 | clientId: process.env.GOOGLE_CLIENT_ID,
30 | clientSecret: process.env.GOOGLE_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | :::warning
37 | Google only provides Refresh Token to an application the first time a user signs in.
38 |
39 | To force Google to re-issue a Refresh Token, the user needs to remove the application from their account and sign in again:
40 | https://myaccount.google.com/permissions
41 |
42 | Alternatively, you can also pass options in the `params` object of `authorization` which will force the Refresh Token to always be provided on sign in, however this will ask all users to confirm if they wish to grant your application access every time they sign in.
43 |
44 | If you need access to the RefreshToken or AccessToken for a Google account and you are not using a database to persist user accounts, this may be something you need to do.
45 |
46 | ```js
47 | const options = {
48 | ...
49 | providers: [
50 | GoogleProvider({
51 | clientId: process.env.GOOGLE_ID,
52 | clientSecret: process.env.GOOGLE_SECRET,
53 | authorization: {
54 | params: {
55 | prompt: "consent",
56 | access_type: "offline",
57 | response_type: "code"
58 | }
59 | }
60 | })
61 | ],
62 | ...
63 | }
64 | ```
65 |
66 | :::
67 |
68 | :::tip
69 | Google also returns a `email_verified` boolean property in the OAuth profile.
70 |
71 | You can use this property to restrict access to people with verified accounts at a particular domain.
72 |
73 | ```js
74 | const options = {
75 | ...
76 | callbacks: {
77 | async signIn({ account, profile }) {
78 | if (account.provider === "google") {
79 | return profile.email_verified && profile.email.endsWith('@example.com')
80 | }
81 | return true // Do different verification for other providers that don't have `email_verified`
82 | },
83 | }
84 | ...
85 | }
86 | ```
87 |
88 | :::
89 |
--------------------------------------------------------------------------------
/docs/providers/identity-server4.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: identity-server4
3 | title: IdentityServer4
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://identityserver4.readthedocs.io/en/latest/
9 |
10 | ## Options
11 |
12 | The **IdentityServer4 Provider** comes with a set of default options:
13 |
14 | - [IdentityServer4 Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/identity-server4.js)
15 |
16 | You can override any of the options to suit your own use case.
17 |
18 | ## Example
19 |
20 | ```js
21 | import IdentityServer4Provider from `next-auth/providers/identity-server4`
22 | ...
23 | providers: [
24 | IdentityServer4Provider({
25 | id: "identity-server4",
26 | name: "IdentityServer4",
27 | issuer: process.env.IdentityServer4_Issuer,
28 | clientId: process.env.IdentityServer4_CLIENT_ID,
29 | clientSecret: process.env.IdentityServer4_CLIENT_SECRET
30 | })
31 | ]
32 | ...
33 | ```
34 |
35 | ## Demo IdentityServer
36 |
37 | The configuration below is for the demo server at https://demo.identityserver.io/
38 |
39 | If you want to try it out, you can copy and paste the configuration below.
40 |
41 | You can sign in to the demo service with either bob/bob or alice/alice.
42 |
43 | ```js
44 | import IdentityServer4Provider from `next-auth/providers/identity-server4`
45 | ...
46 | providers: [
47 | IdentityServer4Provider({
48 | id: "demo-identity-server",
49 | name: "Demo IdentityServer4",
50 | authorization: { params: { scope: "openid profile email api offline_access" } },
51 | issuer: "https://demo.identityserver.io/",
52 | clientId: "interactive.confidential",
53 | clientSecret: "secret",
54 | })
55 | }
56 | ...
57 | ```
58 |
--------------------------------------------------------------------------------
/docs/providers/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: overview
3 | title: Overview
4 | ---
5 |
6 | Authentication Providers in **NextAuth.js** are services that can be used to sign in a user.
7 |
8 | There's four ways a user can be signed in:
9 |
10 | - [Using a built-in OAuth Provider](/configuration/providers/oauth) (e.g Github, Twitter, Google, etc...)
11 | - [Using a custom OAuth Provider](/configuration/providers/oauth#using-a-custom-provider)
12 | - [Using Email](/configuration/providers/email)
13 | - [Using Credentials](/configuration/providers/credentials)
14 |
15 | :::note
16 | NextAuth.js is designed to work with any OAuth service, it supports **OAuth 1.0**, **1.0A**, **2.0** and **OpenID Connect (OIDC)** and has built-in support for most popular sign-in services.
17 | :::
18 |
--------------------------------------------------------------------------------
/docs/providers/instagram.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: instagram
3 | title: Instagram
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.facebook.com/docs/instagram-basic-display-api/getting-started
9 |
10 | ## Configuration
11 |
12 | https://developers.facebook.com/apps/
13 |
14 | ## Options
15 |
16 | The **Instagram Provider** comes with a set of default options:
17 |
18 | - [Instagram Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/instagram.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```jsx
25 | // pages/api/auth/[...nextauth].js
26 | import InstagramProvider from `next-auth/providers/instagram`
27 | ...
28 | providers: [
29 | InstagramProvider({
30 | clientId: process.env.INSTAGRAM_CLIENT_ID,
31 | clientSecret: process.env.INSTAGRAM_CLIENT_SECRET
32 | })
33 | ]
34 | ...
35 | // pages/index.jsx
36 | import { signIn } from "next-auth/react"
37 | ...
38 |
41 | ...
42 | ```
43 |
44 | :::warning
45 | Email address is not returned by the Instagram API.
46 | :::
47 |
48 | :::tip
49 | Instagram display app required callback URL to be configured in your Facebook app and Facebook required you to use **https** even for localhost! In order to do that, you either need to [add an SSL to your localhost](https://www.freecodecamp.org/news/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec/) or use a proxy such as [ngrok](https://ngrok.com/docs).
50 | :::
51 |
--------------------------------------------------------------------------------
/docs/providers/kakao.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: kakao
3 | title: Kakao
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.kakao.com/product/kakaoLogin
9 |
10 | ## Configuration
11 |
12 | https://developers.kakao.com/docs/latest/en/kakaologin/common
13 |
14 | ## Options
15 |
16 | The **Kakao Provider** comes with a set of default options:
17 |
18 | - [Kakao Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/kakao.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import KakaoProvider from `next-auth/providers/kakao`
26 | ...
27 | providers: [
28 | KakaoProvider({
29 | clientId: process.env.KAKAO_CLIENT_ID,
30 | clientSecret: process.env.KAKAO_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | ## Instructions
37 |
38 | ### Configuration
39 |
40 | Create a provider and a Kakao application at `https://developers.kakao.com/console/app`. In the settings of the app under Kakao Login, activate web app, change consent items and configure callback URL.
41 |
--------------------------------------------------------------------------------
/docs/providers/keycloak.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: keycloak
3 | title: Keycloak
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://www.keycloak.org/docs/latest/server_admin/#_oidc_clients
9 |
10 | ## Configuration
11 |
12 | :::tip
13 | Create an openid-connect client in Keycloak with "confidential" as the "Access Type".
14 | :::
15 |
16 | ## Options
17 |
18 | The **Keycloak Provider** comes with a set of default options:
19 |
20 | - [Keycloak Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/keycloak.ts)
21 |
22 | You can override any of the options to suit your own use case.
23 |
24 | ## Example
25 |
26 | ```js
27 | import KeycloakProvider from `next-auth/providers/keycloak`
28 | ...
29 | providers: [
30 | KeycloakProvider({
31 | clientId: process.env.KEYCLOAK_ID,
32 | clientSecret: process.env.KEYCLOAK_SECRET,
33 | issuer: process.env.KEYCLOAK_ISSUER,
34 | })
35 | ]
36 | ...
37 | ```
38 |
39 | :::note
40 | `issuer` should include the realm – e.g. `https://my-keycloak-domain.com/auth/realms/My_Realm`
41 | :::
42 |
--------------------------------------------------------------------------------
/docs/providers/line.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: line
3 | title: LINE
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.line.biz/en/docs/line-login/integrate-line-login/
9 |
10 | ## Configuration
11 |
12 | https://developers.line.biz/console/
13 |
14 | ## Options
15 |
16 | The **Line Provider** comes with a set of default options:
17 |
18 | - [Line Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/line.ts)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import LineProvider from `next-auth/providers/line`
26 | ...
27 | providers: [
28 | LineProvider({
29 | clientId: process.env.LINE_CLIENT_ID,
30 | clientSecret: process.env.LINE_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | ## Instructions
37 |
38 | ### Configuration
39 |
40 | Create a provider and a LINE login channel at `https://developers.line.biz/console/`. In the settings of the channel under LINE Login, activate web app and configure the following:
41 |
42 | - Callback URL
43 | - http://localhost:3000/api/auth/callback/line
44 |
45 | :::tip
46 | To retrieve email address, you need to apply for Email address permission. Open [Line Developer Console](https://developers.line.biz/console/), go to your Login Channel. Scroll down bottom to find **OpenID Connect** -> **Email address permission**. Click **Apply** and follow the instruction.
47 | :::
48 |
--------------------------------------------------------------------------------
/docs/providers/linkedin.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: linkedin
3 | title: LinkedIn
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://docs.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow
9 |
10 | ## Configuration
11 |
12 | https://www.linkedin.com/developers/apps/
13 |
14 | From the Auth tab get the client ID and client secret. On the same tab, add redirect URLs such as http://localhost:3000/api/auth/callback/linkedin so LinkedIn can correctly redirect back to your application. Finally, head over to the Products tab and enable the "Sign In with LinkedIn" product. The LinkedIn team will review and approve your request before you can test it out.
15 |
16 | 
17 |
18 | ## Options
19 |
20 | The **LinkedIn Provider** comes with a set of default options:
21 |
22 | - [LinkedIn Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/linkedin.ts)
23 |
24 | You can override any of the options to suit your own use case.
25 |
26 | ## Example
27 |
28 | ```js
29 | import LinkedInProvider from `next-auth/providers/linkedin`
30 | ...
31 | providers: [
32 | LinkedInProvider({
33 | clientId: process.env.LINKEDIN_CLIENT_ID,
34 | clientSecret: process.env.LINKEDIN_CLIENT_SECRET
35 | })
36 | ]
37 | ...
38 | ```
39 |
--------------------------------------------------------------------------------
/docs/providers/mailchimp.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: mailchimp
3 | title: Mailchimp
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://mailchimp.com/developer/marketing/guides/access-user-data-oauth-2/
9 |
10 | ## Configuration
11 |
12 | https://admin.mailchimp.com/account/oauth2/client/
13 |
14 | ## Options
15 |
16 | The **Mailchimp Provider** comes with a set of default options:
17 |
18 | - [Mailchimp Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/mailchimp.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import MailchimpProvider from `next-auth/providers/mailchimp`
26 | ...
27 | providers: [
28 | MailchimpProvider({
29 | clientId: process.env.MAILCHIMP_CLIENT_ID,
30 | clientSecret: process.env.MAILCHIMP_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/docs/providers/mailru.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: mailru
3 | title: Mail.ru
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://o2.mail.ru/docs
9 |
10 | ## Configuration
11 |
12 | https://o2.mail.ru/app/
13 |
14 | ## Options
15 |
16 | The **Mail.ru Provider** comes with a set of default options:
17 |
18 | - [Mail.ru Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/mailru.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import MailRuProvider from `next-auth/providers/mailru`
26 | ...
27 | providers: [
28 | MailRuProvider({
29 | clientId: process.env.MAILRU_CLIENT_ID,
30 | clientSecret: process.env.MAILRU_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/docs/providers/medium.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: medium
3 | title: Medium
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://github.com/Medium/medium-api-docs
9 |
10 | ## Configuration
11 |
12 | https://medium.com/me/applications
13 |
14 | ## Options
15 |
16 | The **Medium Provider** comes with a set of default options:
17 |
18 | - [Medium Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/medium.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import MediumProvider from `next-auth/providers/medium`
26 | ...
27 | providers: [
28 | MediumProvider({
29 | clientId: process.env.MEDIUM_CLIENT_ID,
30 | clientSecret: process.env.MEDIUM_CLIENT_SECRET
31 | })
32 | }
33 | ...
34 | ```
35 |
36 | :::warning
37 | Email address is not returned by the Medium API.
38 | :::
39 |
--------------------------------------------------------------------------------
/docs/providers/naver.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: naver
3 | title: Naver
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.naver.com/docs/login/overview/overview.md
9 |
10 | ## Configuration
11 |
12 | https://developers.naver.com/docs/login/api/api.md
13 |
14 | ## Options
15 |
16 | The **Naver Provider** comes with a set of default options:
17 |
18 | - [Naver Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/naver.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import NaverProvider from `next-auth/providers/naver`
26 | ...
27 | providers: [
28 | NaverProvider({
29 | clientId: process.env.NAVER_CLIENT_ID,
30 | clientSecret: process.env.NAVER_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/docs/providers/netlify.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: netlify
3 | title: Netlify
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://www.netlify.com/blog/2016/10/10/integrating-with-netlify-oauth2/
9 |
10 | ## Configuration
11 |
12 | https://github.com/netlify/netlify-oauth-example
13 |
14 | ## Options
15 |
16 | The **Netlify Provider** comes with a set of default options:
17 |
18 | - [Netlify Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/netlify.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import NetlifyProvider from `next-auth/providers/netlify`
26 | ...
27 | providers: [
28 | NetlifyProvider({
29 | clientId: process.env.NETLIFY_CLIENT_ID,
30 | clientSecret: process.env.NETLIFY_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/docs/providers/okta.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: okta
3 | title: Okta
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developer.okta.com/docs/reference/api/oidc
9 |
10 | ## Options
11 |
12 | The **Okta Provider** comes with a set of default options:
13 |
14 | - [Okta Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/okta.ts)
15 |
16 | You can override any of the options to suit your own use case.
17 |
18 | ## Example
19 |
20 | ```js
21 | import OktaProvider from `next-auth/providers/okta`
22 | ...
23 | providers: [
24 | OktaProvider({
25 | clientId: process.env.OKTA_CLIENT_ID,
26 | clientSecret: process.env.OKTA_CLIENT_SECRET,
27 | issuer: process.env.OKTA_ISSUER
28 | })
29 | ]
30 | ...
31 | ```
32 |
--------------------------------------------------------------------------------
/docs/providers/onelogin.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: onelogin
3 | title: OneLogin
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.onelogin.com/openid-connect
9 |
10 | ## Configuration
11 |
12 | https://developers.onelogin.com/openid-connect/connect-to-onelogin
13 |
14 | ## Options
15 |
16 | The **OneLogin Provider** comes with a set of default options:
17 |
18 | - [OneLogin Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/onelogin.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import OneLoginProvider from `next-auth/providers/onelogin`
26 | ...
27 | providers: [
28 | OneLoginProvider({
29 | clientId: process.env.ONELOGIN_CLIENT_ID,
30 | clientSecret: process.env.ONELOGIN_CLIENT_SECRET,
31 | issuer: process.env.ONELOGIN_ISSUER
32 | })
33 | ]
34 | ...
35 | ```
36 |
--------------------------------------------------------------------------------
/docs/providers/osso.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: osso
3 | title: Osso
4 | ---
5 |
6 | ## Documentation
7 |
8 | Osso is an open source service that handles SAML authentication against Identity Providers, normalizes profiles, and makes those profiles available to you in an OAuth 2.0 code grant flow.
9 |
10 | If you don't yet have an Osso instance, you can use [Osso's Demo App](https://demo.ossoapp.com) for your testing purposes. For documentation on deploying an Osso instance, see https://ossoapp.com/docs/deploy/overview/
11 |
12 | ## Configuration
13 |
14 | You can configure your OAuth Clients on your Osso Admin UI, i.e. https://demo.ossoapp.com/admin/config - you'll need to get a Client ID and Secret and allow-list your redirect URIs.
15 |
16 | [SAML SSO differs a bit from OAuth](https://ossoapp.com/blog/saml-vs-oauth) - for every tenant who wants to sign in to your application using SAML, you and your customer need to perform a multi-step configuration in Osso's Admin UI and the admin dashboard of the tenant's Identity Provider. Osso provides documentation for providers like Okta and OneLogin, cloud-based IDPs who also offer a developer account that's useful for testing. Osso also provides a [Mock IDP](https://idp.ossoapp.com) that you can use for testing without needing to sign up for an Identity Provider service.
17 |
18 | See Osso's complete configuration and testing documentation at https://ossoapp.com/docs/configure/overview
19 |
20 | ## Options
21 |
22 | The **Osso Provider** comes with a set of default options:
23 |
24 | - [Osso Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/osso.js)
25 |
26 | You can override any of the options to suit your own use case.
27 |
28 | ## Example
29 |
30 | A full example application is available at https://github.com/enterprise-oss/osso-next-auth-example and https://nextjs-demo.ossoapp.com
31 |
32 | ```js
33 | import OssoProvider from `next-auth/providers/osso`
34 | ...
35 | providers: [
36 | OssoProvider({
37 | clientId: process.env.OSSO_CLIENT_ID,
38 | clientSecret: process.env.OSSO_CLIENT_SECRET,
39 | issuer: process.env.OSSO_ISSUER
40 | })
41 | }
42 | ...
43 | ```
44 |
45 | :::note
46 | `issuer` should be the fully qualified domain – e.g. `demo.ossoapp.com`
47 | :::
48 |
--------------------------------------------------------------------------------
/docs/providers/osu.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: osu
3 | title: Osu!
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://osu.ppy.sh/docs/index.html#authentication
9 |
10 | ## Configuration
11 |
12 | https://osu.ppy.sh/home/account/edit#new-oauth-application
13 |
14 | ## Options
15 |
16 | The **Osu Provider** comes with a set of default options:
17 |
18 | - [Osu Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/osu.ts)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 |
23 | :::note
24 | Osu! does **not** provide a user email!
25 | :::
26 |
27 |
28 | ## Example
29 |
30 | ```js
31 | import OsuProvider from `next-auth/providers/osu`
32 | ...
33 | providers: [
34 | OsuProvider({
35 | clientId: process.env.OSU_CLIENT_ID,
36 | clientSecret: process.env.OSU_CLIENT_SECRET
37 | })
38 | ]
39 | ...
40 | ```
41 |
--------------------------------------------------------------------------------
/docs/providers/pipedrive.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: pipedrive
3 | title: Pipedrive
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://pipedrive.readme.io/docs/marketplace-oauth-authorization
9 |
10 | ## Options
11 |
12 | The **Pipedrive Provider** comes with a set of default options:
13 |
14 | - [Pipedrive Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/pipedrive.ts)
15 |
16 | You can override any of the options to suit your own use case.
17 |
18 | ## Example
19 |
20 | ```js
21 | import PipedriveProvider from 'next-auth/providers/pipedrive'
22 | ...
23 | providers: [
24 | PipedriveProvider({
25 | clientId: process.env.PIPEDRIVE_CLIENT_ID,
26 | clientSecret: process.env.PIPEDRIVE_CLIENT_SECRET,
27 | })
28 | ]
29 | ...
30 | ```
--------------------------------------------------------------------------------
/docs/providers/reddit.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: reddit
3 | title: Reddit
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://www.reddit.com/dev/api/
9 |
10 | ## Configuration
11 |
12 | https://www.reddit.com/prefs/apps/
13 |
14 | ## Options
15 |
16 | The **Reddit Provider** comes with a set of default options:
17 |
18 | - [Reddit Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/reddit.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import RedditProvider from `next-auth/providers/reddit`
26 | ...
27 | providers: [
28 | RedditProvider({
29 | clientId: process.env.REDDIT_CLIENT_ID,
30 | clientSecret: process.env.REDDIT_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | :::warning
37 | Reddit requires authorization every time you go through their page.
38 | :::
39 |
40 | :::warning
41 | Only allows one callback URL per Client ID / Client Secret.
42 | :::
43 |
44 | :::tip
45 | This Provider template only has a one hour access token to it and only has the 'identity' scope. If you want to get a refresh token as well you must follow this:
46 |
47 | ```js
48 | providers: [
49 | {
50 | id: "reddit",
51 | name: "Reddit",
52 | clientId: process.env.REDDIT_CLIENT_ID,
53 | clientSecret: process.env.REDDIT_CLIENT_SECRET,
54 | scope: "identity mysubreddits read", //Check Reddit API Documentation for more. The identity scope is required.
55 | type: "oauth",
56 | version: "2.0",
57 | params: { grant_type: "authorization_code" },
58 | accessTokenUrl: " https://www.reddit.com/api/v1/access_token",
59 | authorizationUrl:
60 | "https://www.reddit.com/api/v1/authorize?response_type=code&duration=permanent",
61 | profileUrl: "https://oauth.reddit.com/api/v1/me",
62 | profile: (profile) => {
63 | return {
64 | id: profile.id,
65 | name: profile.name,
66 | email: null,
67 | }
68 | },
69 | },
70 | ]
71 | ```
72 |
73 | :::
74 |
--------------------------------------------------------------------------------
/docs/providers/salesforce.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: salesforce
3 | title: Salesforce
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://help.salesforce.com/articleView?id=remoteaccess_authenticate.htm&type=5
9 |
10 | ## Options
11 |
12 | The **Salesforce Provider** comes with a set of default options:
13 |
14 | - [Salesforce Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/salesforce.js)
15 |
16 | You can override any of the options to suit your own use case.
17 |
18 | ## Example
19 |
20 | ```js
21 | import SalesforceProvider from `next-auth/providers/salesforce`
22 | ...
23 | providers: [
24 | SalesforceProvider({
25 | clientId: process.env.SALESFORCE_CLIENT_ID,
26 | clientSecret: process.env.SALESFORCE_CLIENT_SECRET,
27 | })
28 | ]
29 | ...
30 | ```
31 |
--------------------------------------------------------------------------------
/docs/providers/slack.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: slack
3 | title: Slack
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://api.slack.com/authentication
9 | https://api.slack.com/docs/sign-in-with-slack
10 |
11 | ## Configuration
12 |
13 | https://api.slack.com/apps
14 |
15 | :::warning
16 | Slack requires you that the redirect URL of your app uses `https`, even for local development. An easy workaround for this is using a service like [`ngrok`](https://ngrok.com) that creates a secure tunnel to your app, using `https`. Remember to set the url as `NEXTAUTH_URL` as well.
17 | :::
18 |
19 | 
20 |
21 | ## Options
22 |
23 | The **Slack Provider** comes with a set of default options:
24 |
25 | - [Slack Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/slack.ts)
26 |
27 | You can override any of the options to suit your own use case.
28 |
29 | ## Example
30 |
31 | ```js
32 | import SlackProvider from `next-auth/providers/slack`
33 | ...
34 | providers: [
35 | SlackProvider({
36 | clientId: process.env.SLACK_CLIENT_ID,
37 | clientSecret: process.env.SLACK_CLIENT_SECRET
38 | })
39 | ]
40 | ...
41 | ```
42 |
--------------------------------------------------------------------------------
/docs/providers/spotify.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: spotify
3 | title: Spotify
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developer.spotify.com/documentation/general/guides/authorization-guide
9 |
10 | ## Configuration
11 |
12 | https://developer.spotify.com/dashboard/applications
13 |
14 | ## Options
15 |
16 | The **Spotify Provider** comes with a set of default options:
17 |
18 | - [Spotify Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/spotify.ts)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import SpotifyProvider from `next-auth/providers/spotify`
26 | ...
27 | providers: [
28 | SpotifyProvider({
29 | clientId: process.env.SPOTIFY_CLIENT_ID,
30 | clientSecret: process.env.SPOTIFY_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/docs/providers/strava.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: strava
3 | title: Strava
4 | ---
5 |
6 | ## Documentation
7 |
8 | http://developers.strava.com/docs/reference/
9 |
10 | ## Options
11 |
12 | The **Strava Provider** comes with a set of default options:
13 |
14 | - [Strava Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/strava.js)
15 |
16 | You can override any of the options to suit your own use case.
17 |
18 | ## Example
19 |
20 | ```js
21 | import StravaProvider from 'next-auth/providers/strava'
22 | ...
23 | providers: [
24 | StravaProvider({
25 | clientId: process.env.STRAVA_CLIENT_ID,
26 | clientSecret: process.env.STRAVA_CLIENT_SECRET,
27 | })
28 | ]
29 | ...
30 | ```
31 |
--------------------------------------------------------------------------------
/docs/providers/twitch.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: twitch
3 | title: Twitch
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://dev.twitch.tv/docs/authentication
9 |
10 | ## Configuration
11 |
12 | https://dev.twitch.tv/console/apps
13 |
14 | Add the following redirect URL into the console `http:///api/auth/callback/twitch`
15 |
16 | ## Options
17 |
18 | The **Twitch Provider** comes with a set of default options:
19 |
20 | - [Twitch Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/twitch.ts)
21 |
22 | You can override any of the options to suit your own use case.
23 |
24 | ## Example
25 |
26 | ```js
27 | import TwitchProvider from `next-auth/providers/twitch`
28 | ...
29 | providers: [
30 | TwitchProvider({
31 | clientId: process.env.TWITCH_CLIENT_ID,
32 | clientSecret: process.env.TWITCH_CLIENT_SECRET
33 | })
34 | ]
35 | ...
36 | ```
37 |
--------------------------------------------------------------------------------
/docs/providers/twitter.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: twitter
3 | title: Twitter
4 | ---
5 |
6 | :::note
7 | Twitter is currently the only built-in provider using the OAuth 1.0 spec. This means that you won't receive an `access_token` or `refresh_token`, but an `oauth_token` and `oauth_token_secret` respectively. Remember to add these to your database schema, in case if you are using an [Adapter](/adapters/overview).
8 | :::
9 |
10 | ## Documentation
11 |
12 | https://developer.twitter.com
13 |
14 | ## Configuration
15 |
16 | https://developer.twitter.com/en/apps
17 |
18 | ## Options
19 |
20 | The **Twitter Provider** comes with a set of default options:
21 |
22 | - [Twitter Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/twitter.ts)
23 |
24 | You can override any of the options to suit your own use case.
25 |
26 | ## Example
27 |
28 | ```js
29 | import TwitterProvider from `next-auth/providers/twitter`
30 | ...
31 | providers: [
32 | TwitterProvider({
33 | clientId: process.env.TWITTER_CLIENT_ID,
34 | clientSecret: process.env.TWITTER_CLIENT_SECRET
35 | })
36 | ]
37 | ...
38 | ```
39 |
40 | :::tip
41 | You must enable the _"Request email address from users"_ option in your app permissions if you want to obtain the users email address.
42 | :::
43 |
44 | 
45 |
--------------------------------------------------------------------------------
/docs/providers/vk.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: vk
3 | title: VK
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://vk.com/dev/first_guide
9 |
10 | ## Configuration
11 |
12 | https://vk.com/apps?act=manage
13 |
14 | ## Options
15 |
16 | The **VK Provider** comes with a set of default options:
17 |
18 | - [VK Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/vk.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import VkProvider from `next-auth/providers/vk`
26 | ...
27 | providers: [
28 | VkProvider({
29 | clientId: process.env.VK_CLIENT_ID,
30 | clientSecret: process.env.VK_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | :::note
37 | By default the provider uses `5.126` version of the API. See https://vk.com/dev/versions for more info.
38 | :::
39 |
40 | If you want to use a different version, you can pass it to provider's options object:
41 |
42 | ```js
43 | // pages/api/auth/[...nextauth].js
44 |
45 | const apiVersion = "5.126"
46 | ...
47 | providers: [
48 | VkProvider({
49 | accessTokenUrl: `https://oauth.vk.com/access_token?v=${apiVersion}`,
50 | requestTokenUrl: `https://oauth.vk.com/access_token?v=${apiVersion}`,
51 | authorizationUrl:
52 | `https://oauth.vk.com/authorize?response_type=code&v=${apiVersion}`,
53 | profileUrl: `https://api.vk.com/method/users.get?fields=photo_100&v=${apiVersion}`,
54 | })
55 | ]
56 | ...
57 | ```
58 |
--------------------------------------------------------------------------------
/docs/providers/wordpress.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: wordpress
3 | title: WordPress.com
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developer.wordpress.com/docs/oauth2/
9 |
10 | ## Configuration
11 |
12 | https://developer.wordpress.com/apps/
13 |
14 | ## Options
15 |
16 | The **Wordpress Provider** comes with a set of default options:
17 |
18 | - [Wordpress Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/wordpress.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import WordpressProvider from `next-auth/providers/wordpress`
26 | ...
27 | providers: [
28 | WordpressProvider({
29 | clientId: process.env.WORDPRESS_CLIENT_ID,
30 | clientSecret: process.env.WORDPRESS_CLIENT_SECRET
31 | })
32 | }
33 | ...
34 | ```
35 |
36 | :::tip
37 | Register your application to obtain Client ID and Client Secret at https://developer.wordpress.com/apps/ Select Type as Web and set Redirect URL to `http://example.com/api/auth/callback/wordpress` where example.com is your site domain.
38 | :::
39 |
--------------------------------------------------------------------------------
/docs/providers/yandex.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: yandex
3 | title: Yandex
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://tech.yandex.com/oauth/doc/dg/concepts/about-docpage/
9 |
10 | ## Configuration
11 |
12 | https://oauth.yandex.com/client/new
13 |
14 | ## Options
15 |
16 | The **Yandex Provider** comes with a set of default options:
17 |
18 | - [Yandex Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/yandex.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import YandexProvider from `next-auth/providers/yandex`
26 | ...
27 | providers: [
28 | YandexProvider({
29 | clientId: process.env.YANDEX_CLIENT_ID,
30 | clientSecret: process.env.YANDEX_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/docs/providers/zoho.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: zoho
3 | title: Zoho
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://www.zoho.com/accounts/protocol/oauth/web-server-applications.html
9 |
10 | ## Configuration
11 |
12 | https://api-console.zoho.com/
13 |
14 | ## Options
15 |
16 | The **Zoho Provider** comes with a set of default options:
17 |
18 | - [Zoho Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/zoho.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import ZohoProvider from `next-auth/providers/zoho`
26 | ...
27 | providers: [
28 | ZohoProvider({
29 | clientId: process.env.ZOHO_CLIENT_ID,
30 | clientSecret: process.env.ZOHO_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/docs/providers/zoom.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: zoom
3 | title: Zoom
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://marketplace.zoom.us/docs/guides/auth/oauth
9 |
10 | ## Configuration
11 |
12 | https://marketplace.zoom.us
13 |
14 | ## Options
15 |
16 | The **Zoom Provider** comes with a set of default options:
17 |
18 | - [Zoom Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/zoom.ts)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import ZoomProvider from `next-auth/providers/zoom`
26 | ...
27 | providers: [
28 | ZoomProvider({
29 | clientId: process.env.ZOOM_CLIENT_ID,
30 | clientSecret: process.env.ZOOM_CLIENT_SECRET
31 | })
32 | }
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/docs/security.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: security
3 | title: Security
4 | ---
5 |
6 | ## Reporting a Vulnerability
7 |
8 | NextAuth.js practices responsible disclosure.
9 |
10 | We request that you contact us directly to report serious issues that might impact the security of sites using NextAuth.js.
11 |
12 | If you contact us regarding a serious issue:
13 |
14 | - We will endeavor to get back to you within 72 hours.
15 | - We will aim to publish a fix within 30 days.
16 | - We will disclose the issue (and credit you, with your consent) once a fix to resolve the issue has been released.
17 | - If 90 days has elapsed and we still don't have a fix, we will disclose the issue publicly.
18 |
19 | The best way to report an issue is by contacting us via email at info@balazsorban.com or me@iaincollins.com and yo@ndo.dev, or raise a public issue requesting someone get in touch with you via whatever means you prefer for more details. (Please do not disclose sensitive details publicly at this stage.)
20 |
21 | :::note
22 | For less serious issues (e.g. RFC compliance for unsupported flows or potential issues that may cause a problem in the future) it is appropriate to submit these these publically as bug reports or feature requests or to raise a question to open a discussion around them.
23 | :::
24 |
25 | ## Supported Versions
26 |
27 | Security updates are only released for the current version.
28 |
29 | Old releases are not maintained and do not receive updates.
30 |
--------------------------------------------------------------------------------
/docs/tutorials/creating-a-database-adapter.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: creating-a-database-adapter
3 | title: Create an adapter
4 | ---
5 |
6 | Using a custom adapter you can connect to any database back-end or even several different databases. Official adapters created and maintained by our community can be found in the [adapters repository](https://github.com/nextauthjs/adapters). Feel free to add a custom adapter from your project to the repository, or even become a maintainer of a certain adapter. Custom adapters can still be created and used in a project without being added to the repository.
7 |
8 | ## How to create an adapter
9 |
10 | _See the code below for practical example._
11 |
12 | ### Example code
13 |
14 | ```ts
15 | /** @return { import("next-auth/adapters").Adapter } */
16 | export default function MyAdapter(client, options = {}) {
17 | return {
18 | async createUser(user) {
19 | return
20 | },
21 | async getUser(id) {
22 | return
23 | },
24 | async getUserByEmail(email) {
25 | return
26 | },
27 | async getUserByAccount({ provider, id }) {
28 | return
29 | },
30 | async updateUser(user) {
31 | return
32 | },
33 | async deleteUser(userId) {
34 | return
35 | },
36 | async linkAccount(account) {
37 | return
38 | },
39 | async unlinkAccount({ provider, id }) {
40 | return
41 | },
42 | async createSession({ sessionToken, userId, expires }) {
43 | return
44 | },
45 | async getSessionAndUser(sessionToken) {
46 | return
47 | },
48 | async updateSession({ sessionToken }) {
49 | return
50 | },
51 | async deleteSession(sessionToken) {
52 | return
53 | },
54 | async createVerificationToken({ identifier, expires, token }) {
55 | return
56 | },
57 | async useVerificationToken({ identifier, token }) {
58 | return
59 | },
60 | }
61 | }
62 | ```
63 |
64 | ### Required methods
65 |
66 | These methods are required for all sign in flows:
67 |
68 | - `createUser`
69 | - `getUser`
70 | - `getUserByEmail`
71 | - `getUserByAccount`
72 | - `linkAccount`
73 | - `createSession`
74 | - `getSessionAndUser`
75 | - `updateSession`
76 | - `deleteSession`
77 | - `updateUser`
78 |
79 | These methods are required to support email / passwordless sign in:
80 |
81 | - `createVerificationToken`
82 | - `useVerificationToken`
83 |
84 | ### Unimplemented methods
85 |
86 | These methods will be required in a future release, but are not yet invoked:
87 |
88 | - `deleteUser`
89 | - `unlinkAccount`
90 |
--------------------------------------------------------------------------------
/docs/tutorials/usage-with-class-components.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: usage-with-class-components
3 | title: Usage with class components
4 | ---
5 |
6 | If you want to use the `useSession()` hook in your class components you can do so with the help of a higher order component or with a render prop.
7 |
8 | ## Higher Order Component
9 |
10 | ```js
11 | import { useSession } from "next-auth/react"
12 |
13 | const withSession = (Component) => (props) => {
14 | const session = useSession()
15 |
16 | // if the component has a render property, we are good
17 | if (Component.prototype.render) {
18 | return
19 | }
20 |
21 | // if the passed component is a function component, there is no need for this wrapper
22 | throw new Error(
23 | [
24 | "You passed a function component, `withSession` is not needed.",
25 | "You can `useSession` directly in your component.",
26 | ].join("\n")
27 | )
28 | }
29 |
30 | // Usage
31 | class ClassComponent extends React.Component {
32 | render() {
33 | const { data: session, status } = this.props.session
34 | return null
35 | }
36 | }
37 |
38 | const ClassComponentWithSession = withSession(ClassComponent)
39 | ```
40 |
41 | ## Render Prop
42 |
43 | ```js
44 | import { useSession } from "next-auth/react"
45 |
46 | const UseSession = ({ children }) => {
47 | const session = useSession()
48 | return children(session)
49 | }
50 |
51 | // Usage
52 | class ClassComponent extends React.Component {
53 | render() {
54 | return (
55 |
56 | {(session) =>
{JSON.stringify(session, null, 2)}
}
57 |
58 | )
59 | }
60 | }
61 | ```
62 |
--------------------------------------------------------------------------------
/docs/warnings.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: warnings
3 | title: Warnings
4 | ---
5 |
6 | This is a list of warning output from NextAuth.js.
7 |
8 | All warnings indicate things which you should take a look at, but do not inhibit normal operation.
9 |
10 | ---
11 |
12 | ## Client
13 |
14 | #### NEXTAUTH_URL
15 |
16 | Environment variable `NEXTAUTH_URL` missing. Please set it in your `.env` file.
17 |
18 | :::note
19 | On [Vercel](https://vercel.com) deployments, we will read the `VERCEL_URL` environment variable, so you won't need to define `NEXTAUTH_URL`.
20 | :::
21 |
22 | ---
23 |
24 | ## Server
25 |
26 | These warnings are displayed on the terminal.
27 |
28 | #### NO_SECRET
29 |
30 | In development, we generate a `secret` based on your configuration for convenience. This is volatile and will throw an error in production. [Read more](https://next-auth.js.org/configuration/options#secret)
31 |
32 | ## Adapter
33 |
34 | ### ADAPTER_TYPEORM_UPDATING_ENTITIES
35 |
36 | This warning occurs when typeorm finds that the provided entities differ from the database entities. By default while not in `production` the typeorm adapter will always synchronize changes made to the entities codefiles.
37 |
38 | Disable this warning by setting `synchronize: false` in your typeorm config
39 |
40 | Example:
41 |
42 | ```js title="/pages/api/auth/[...nextauth].js"
43 | adapter: TypeORMLegacyAdapter({
44 | type: 'mysql',
45 | username: process.env.DATABASE_USERNAME,
46 | password: process.env.DATABASE_PASSWORD,
47 | host: process.env.DATABASE_HOST,
48 | database: process.env.DATABASE_DB,
49 | synchronize: false
50 | }),
51 | ```
52 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "next-auth-docs",
3 | "version": "0.2.0",
4 | "repository": {
5 | "type": "git",
6 | "url": "git://github.com/nextauthjs/docs.git"
7 | },
8 | "scripts": {
9 | "start": "npm run generate-providers && docusaurus start",
10 | "dev": "npm run start",
11 | "build": "npm run generate-providers && docusaurus build",
12 | "docusaurus": "docusaurus",
13 | "swizzle": "docusaurus swizzle",
14 | "deploy": "docusaurus deploy",
15 | "serve": "docusaurus serve",
16 | "clear": "docusaurus clear",
17 | "lint": "standard",
18 | "lint:fix": "standard --fix",
19 | "generate-providers": "node ./scripts/generate-providers.js"
20 | },
21 | "dependencies": {
22 | "@docusaurus/core": "2.0.0-beta.9",
23 | "@docusaurus/preset-classic": "2.0.0-beta.9",
24 | "@docusaurus/remark-plugin-npm2yarn": "^2.0.0-beta.9",
25 | "classnames": "^2.3.1",
26 | "lodash.times": "^4.3.2",
27 | "react": "^17.0.2",
28 | "react-dom": "^17.0.2",
29 | "react-marquee-slider": "^1.1.5",
30 | "remark-github": "^10.1.0",
31 | "remark-mermaid-dataurl": "^1.0.2",
32 | "styled-components": "^5.3.3"
33 | },
34 | "browserslist": {
35 | "production": [
36 | ">0.2%",
37 | "not dead",
38 | "not op_mini all"
39 | ],
40 | "development": [
41 | "last 1 chrome version",
42 | "last 1 firefox version",
43 | "last 1 safari version"
44 | ]
45 | },
46 | "prettier": {
47 | "semi": false,
48 | "singleQuote": false
49 | },
50 | "devDependencies": {
51 | "prettier": "^2.5.0",
52 | "standard": "^16.0.4"
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/scripts/generate-providers.js:
--------------------------------------------------------------------------------
1 | const path = require("path")
2 | const fs = require("fs")
3 |
4 | const providersPath = path.join(process.cwd(), "/docs/providers")
5 |
6 | const files = fs.readdirSync(providersPath, "utf8")
7 |
8 | const result = files.reduce((acc, file) => {
9 | if (file === "overview.md") return acc
10 | const provider = fs.readFileSync(path.join(providersPath, file), "utf8")
11 | const { id, title } = provider.match(
12 | /id: (?.+)\ntitle: (?.+)\n/
13 | ).groups
14 | acc[id] = title
15 | return acc
16 | }, {})
17 |
18 | fs.writeFileSync(
19 | path.join(process.cwd(), "providers.json"),
20 | JSON.stringify(result, null, 2)
21 | )
22 |
--------------------------------------------------------------------------------
/sidebars.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | docs: [
3 | {
4 | type: "category",
5 | label: "Getting Started",
6 | collapsed: false,
7 | items: [
8 | "getting-started/introduction",
9 | "getting-started/example",
10 | "getting-started/client",
11 | "getting-started/rest-api",
12 | "getting-started/typescript",
13 | "getting-started/upgrade-v4",
14 | ],
15 | },
16 | {
17 | type: "category",
18 | label: "Configuration",
19 | collapsed: true,
20 | items: [
21 | "configuration/initialization",
22 | "configuration/options",
23 | {
24 | type: "category",
25 | label: "Providers",
26 | collapsed: true,
27 | items: [
28 | "configuration/providers/oauth",
29 | "configuration/providers/email",
30 | "configuration/providers/credentials",
31 | ],
32 | },
33 | "configuration/databases",
34 | "configuration/pages",
35 | "configuration/callbacks",
36 | "configuration/events",
37 | ],
38 | },
39 | {
40 | type: "category",
41 | label: "Providers",
42 | collapsed: true,
43 | items: [
44 | "providers/overview",
45 | // TODO: Overview included twice due to autogeneration
46 | {
47 | type: "autogenerated",
48 | dirName: "providers",
49 | },
50 | ],
51 | },
52 | {
53 | type: "category",
54 | label: "Adapters",
55 | collapsed: true,
56 | items: [
57 | "adapters/overview",
58 | "adapters/models",
59 | "adapters/prisma",
60 | "adapters/fauna",
61 | "adapters/dynamodb",
62 | "adapters/firebase",
63 | "adapters/pouchdb",
64 | "adapters/mongodb",
65 | "adapters/neo4j",
66 | "adapters/typeorm",
67 | "adapters/sequelize",
68 | "adapters/mikro-orm",
69 | "adapters/dgraph",
70 | ],
71 | },
72 | "warnings",
73 | "errors",
74 | ],
75 | }
76 |
--------------------------------------------------------------------------------
/src/components/ProviderMarquee.js:
--------------------------------------------------------------------------------
1 | import React from "react"
2 | import Marquee, { Motion, randomIntFromInterval } from "react-marquee-slider"
3 | import * as S from "./ProviderMarqueeStyle"
4 | import times from "lodash.times"
5 |
6 | const icons = [
7 | "/img/providers/apple-black.svg",
8 | "/img/providers/auth0.svg",
9 | "/img/providers/aws-cognito.svg",
10 | "/img/providers/battle.net.svg",
11 | "/img/providers/box.svg",
12 | "/img/providers/facebook-2.svg",
13 | "/img/providers/github-1.svg",
14 | "/img/providers/gitlab.svg",
15 | "/img/providers/google-icon.svg",
16 | "/img/providers/okta-3.svg",
17 | "/img/providers/openid.svg",
18 | "/img/providers/slack.svg",
19 | "/img/providers/spotify.svg",
20 | "/img/providers/twitter.svg",
21 | ]
22 |
23 | const ProviderMarquee = React.memo(({ size }) => {
24 | let scale = 0.4
25 |
26 | if (typeof window !== "undefined") {
27 | const width = window.outerWidth
28 | if (width > 800) {
29 | scale = 0.6
30 | }
31 |
32 | if (width > 1100) {
33 | scale = 0.7
34 | }
35 |
36 | if (width > 1400) {
37 | scale = 0.8
38 | }
39 | }
40 |
41 | return (
42 |
43 |
44 |
67 |
68 |
69 | )
70 | })
71 |
72 | export default ProviderMarquee
73 |
--------------------------------------------------------------------------------
/src/components/ProviderMarqueeStyle.js:
--------------------------------------------------------------------------------
1 | import styled from "styled-components"
2 |
3 | export const Circle = styled.div`
4 | position: absolute;
5 | object-position: center center;
6 | will-change: transform, opacity;
7 | width: ${(props) => props.scale * 150}px;
8 | height: ${(props) => props.scale * 150}px;
9 | top: -50%;
10 | left: -50%;
11 | border-radius: 50%;
12 | display: flex;
13 | justify-content: center;
14 | align-items: center;
15 | margin-top: 1rem;
16 | `
17 |
18 | export const Logo = styled.img`
19 | display: block;
20 | width: 65%;
21 | height: 65%;
22 | filter: grayscale(100%);
23 | opacity: 0.1;
24 | `
25 |
26 | export const FullWidth = styled.div`
27 | width: 100vw;
28 | position: relative;
29 | left: 50%;
30 | right: 50%;
31 | margin-left: -50vw;
32 | margin-right: -50vw;
33 | `
34 |
35 | export const Height = styled.div`
36 | position: relative;
37 | width: 100%;
38 | height: ${(props) => (props.height ? props.height + "px" : "auto")};
39 | `
40 |
41 | export const Company = styled.div`
42 | position: relative;
43 | width: ${(props) => props.scale * 75}px;
44 | height: ${(props) => props.scale * 75}px;
45 | `
46 |
--------------------------------------------------------------------------------
/src/css/admonitions.css:
--------------------------------------------------------------------------------
1 | .admonition-icon {
2 | margin-right: 0.5rem;
3 | }
4 |
5 | .admonition.admonition-tip,
6 | .admonition.admonition-note,
7 | .admonition.admonition-warning {
8 | background-color: #f9f9f9;
9 | color: #444;
10 | border: none;
11 | border-left: 0.4rem solid #666;
12 | border-radius: 0;
13 | }
14 |
15 | .admonition.admonition-tip a,
16 | .admonition.admonition-note a,
17 | .admonition.admonition-warning a {
18 | color: #444;
19 | }
20 |
21 | .admonition-icon svg {
22 | fill: #444;
23 | }
24 |
25 | .admonition.admonition-note .admonition-icon svg,
26 | .admonition.admonition-note .admonition-heading {
27 | color: #444;
28 | fill: #444;
29 | }
30 |
31 | html[data-theme="dark"] .admonition.admonition-note .admonition-icon svg,
32 | html[data-theme="dark"] .admonition.admonition-note .admonition-heading {
33 | color: #888;
34 | fill: #888;
35 | }
36 |
37 | html[data-theme="dark"] .admonition.admonition-tip,
38 | html[data-theme="dark"] .admonition.admonition-note,
39 | html[data-theme="dark"] .admonition.admonition-warning {
40 | color: #eee;
41 | background-color: #222;
42 | }
43 |
44 | html[data-theme="dark"] .admonition.admonition-tip a,
45 | html[data-theme="dark"] .admonition.admonition-note a,
46 | html[data-theme="dark"] .admonition.admonition-warning a {
47 | color: #eee;
48 | }
49 |
50 | .admonition.admonition-tip {
51 | border-color: var(--ifm-color-info);
52 | }
53 |
54 | .admonition.admonition-tip .admonition-icon svg,
55 | .admonition.admonition-tip .admonition-heading {
56 | color: var(--ifm-color-info);
57 | fill: var(--ifm-color-info);
58 | }
59 |
60 | .admonition.admonition-warning {
61 | border-color: var(--ifm-color-warning);
62 | }
63 |
64 | .admonition.admonition-warning .admonition-icon svg,
65 | .admonition.admonition-warning .admonition-heading {
66 | color: var(--ifm-color-warning);
67 | fill: var(--ifm-color-warning);
68 | }
69 |
70 | .admonition.alert--success {
71 | --ifm-alert-background-color: var(--ifm-background-color);
72 | --ifm-alert-background-color-highlight: #03a7fa10;
73 | --ifm-alert-foreground-color: var(--ifm-color-primary);
74 | --ifm-alert-border-color: var(--ifm-color-success);
75 | }
76 |
--------------------------------------------------------------------------------
/src/css/buttons.css:
--------------------------------------------------------------------------------
1 | .button {
2 | border: none;
3 | transition-duration: 0s;
4 | box-shadow: 0 0 2rem rgba(0, 0, 0, 0.1);
5 | filter: brightness(100%);
6 | }
7 |
8 | .button:hover,
9 | .button:active {
10 | filter: brightness(105%);
11 | }
12 |
13 | html[data-theme="dark"] .button:hover,
14 | html[data-theme="dark"] .button:active {
15 | filter: brightness(105%);
16 | }
17 |
18 | .button--primary,
19 | .button--primary:hover {
20 | background: linear-gradient(0deg, #1786fb 0%, #2cfefe 100%) !important;
21 | color: #fff;
22 | }
23 |
24 | .button.button--secondary.button--outline,
25 | .button.button--secondary.button--outline:link,
26 | .button.button--secondary.button--outline:visited,
27 | .button.button--secondary.button--outline:hover,
28 | .button.button--secondary.button--outline:active {
29 | background: linear-gradient(0deg, #eeeeee 0%, #ffffff 100%) !important;
30 | background: #fff !important;
31 | color: #222 !important;
32 | }
33 |
34 | html[data-theme="dark"] .button.button--secondary.button--outline {
35 | background: linear-gradient(0deg, #000000 0%, #222222 100%) !important;
36 | background: #111 !important;
37 | color: #eee !important;
38 | }
39 |
--------------------------------------------------------------------------------
/src/css/navbar.css:
--------------------------------------------------------------------------------
1 | .navbar {
2 | box-shadow: none;
3 | }
4 |
5 | .navbar__toggle {
6 | margin-right: 1rem !important;
7 | }
8 |
9 | .navbar__title {
10 | font-size: 1.2rem;
11 | margin-left: 0.2rem;
12 | display: none;
13 | }
14 |
15 | .navbar-sidebar__brand .navbar__title {
16 | display: inline;
17 | }
18 |
19 | .navbar__item.navbar__link[href*="github"],
20 | .navbar__item.navbar__link[href*="npmjs"] {
21 | position: relative;
22 | padding: 0 1.5rem 0 0;
23 | display: flex;
24 | font-size: 0;
25 | }
26 |
27 | .navbar__item.navbar__link[href*="github"]:before {
28 | content: "";
29 | width: 1.5rem;
30 | height: 1.5rem;
31 | background-image: url("/img/brand-github.svg");
32 | background-repeat: no-repeat;
33 | }
34 |
35 | .navbar__items .react-toggle {
36 | margin-right: 5px;
37 | }
38 |
39 | .react-toggle--focus .react-toggle-thumb,
40 | .react-toggle:hover .react-toggle-thumb {
41 | box-shadow: none !important;
42 | }
43 |
44 | .navbar__search-input:focus {
45 | outline: none;
46 | box-shadow: rgb(255, 255, 255) 0px 0px 0px 0px,
47 | rgba(19, 19, 19, 0.2) 0px 0px 0px 4px, rgba(0, 0, 0, 0) 0px 0px 0px 0px;
48 | transition: box-shadow 350ms ease-in-out;
49 | }
50 | html[data-theme="dark"] .navbar__search-input:focus {
51 | box-shadow: rgb(255, 255, 255) 0px 0px 0px 0px,
52 | rgba(29, 29, 29, 0.5) 0px 0px 0px 4px, rgba(0, 0, 0, 0) 0px 0px 0px 0px;
53 | }
54 |
55 | html[data-theme="dark"] .navbar__item.navbar__link[href*="github"]:before {
56 | background-image: url("/img/brand-github-inverted.svg");
57 | }
58 |
59 | .navbar__item.navbar__link[href*="npmjs"]:before {
60 | content: "";
61 | width: 3rem;
62 | height: 1.2rem;
63 | margin-top: 0.2rem;
64 | background-image: url("/img/brand-npm.svg");
65 | background-repeat: no-repeat;
66 | }
67 |
68 | html[data-theme="dark"] .navbar__item.navbar__link[href*="npm"]:before {
69 | background-image: url("/img/brand-npm-inverted.svg");
70 | }
71 |
72 | @media screen and (max-width: 966px) {
73 | .navbar__item.navbar__link[href*="github"],
74 | .navbar__item.navbar__link[href*="npmjs"] {
75 | display: none;
76 | }
77 | }
78 |
79 | @media screen and (min-width: 420px) {
80 | .navbar__title {
81 | display: inline;
82 | }
83 | }
84 |
85 | .github-counter {
86 | position: absolute;
87 | color: #000;
88 | top: -10px;
89 | right: 5px;
90 | font-size: 9px;
91 | background-color: #ccc;
92 | padding: 2px 5px;
93 | border-radius: 10px;
94 | z-index: -1;
95 | }
96 |
97 | html[data-theme="dark"] .github-counter {
98 | background-color: #222;
99 | color: #fff;
100 | }
101 |
--------------------------------------------------------------------------------
/src/css/providers.css:
--------------------------------------------------------------------------------
1 | .provider-name-list {
2 | display: flex;
3 | flex-wrap: wrap;
4 | }
5 |
6 | .provider-name-list__comma {
7 | display: inline-flex;
8 | margin-right: 5px;
9 | }
10 |
--------------------------------------------------------------------------------
/src/css/search.css:
--------------------------------------------------------------------------------
1 | html[data-theme="light"]:root {
2 | --docsearch-searchbox-shadow: inset 0 0 0 2px #a553b3;
3 | }
4 |
5 | html[data-theme="light"] .DocSearch-Modal .DocSearch-Search-Icon {
6 | color: #a553b3;
7 | }
8 |
9 | html[data-theme="dark"] .DocSearch-Modal .DocSearch-Search-Icon {
10 | color: #7c2f89;
11 | }
12 |
13 | html[data-theme="dark"]:root {
14 | --docsearch-searchbox-background: #040404;
15 | --docsearch-key-gradient: #000;
16 | --docsearch-key-shadow: #ccc;
17 | --docsearch-searchbox-shadow: inset 0 0 0 2px #7c2f89;
18 | }
19 |
20 | html[data-theme="dark"] .DocSearch-Button-Key {
21 | --docsearch-muted-color: #333;
22 | }
23 |
24 | @media screen and (max-width: 740px) {
25 | .DocSearch-Container {
26 | margin-top: 60px;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/pages/index.module.css:
--------------------------------------------------------------------------------
1 | /* stylelint-disable docusaurus/copyright-header */
2 | /**
3 | * CSS files with the .module.css suffix will be treated as CSS modules
4 | * and scoped locally.
5 | */
6 |
7 | .heroBanner {
8 | padding: 4rem 0 0 0;
9 | text-align: center;
10 | position: relative;
11 | }
12 |
13 | @media screen and (max-width: 966px) {
14 | .heroBanner {
15 | padding: 2rem 2rem 0 2rem;
16 | }
17 | }
18 |
19 | .heroLogo {
20 | margin-bottom: 0.5rem;
21 | width: 8rem;
22 | }
23 |
24 | @media screen and (min-width: 689px) {
25 | .heroLogo {
26 | margin-bottom: -0.5rem;
27 | }
28 | }
29 |
30 | @media screen and (min-width: 689px) {
31 | .heroText {
32 | display: inline-block;
33 | margin: 1rem 1.5rem 0 2rem;
34 | }
35 | }
36 |
37 | .buttons {
38 | display: flex;
39 | align-items: center;
40 | justify-content: center;
41 | padding: 4rem 1rem 0 1rem;
42 | }
43 |
44 | .button {
45 | margin: 0 0.5rem;
46 | }
47 |
48 | .features {
49 | display: flex;
50 | align-items: center;
51 | padding-top: 4rem;
52 | margin: 0 auto 0 auto;
53 | width: 100%;
54 | }
55 |
56 | .featuresTitle {
57 | font-size: 2.5rem;
58 | line-height: 3rem;
59 | margin: 2rem 0 4rem 0;
60 | text-align: center;
61 | font-weight: 800 !important;
62 | }
63 |
64 | .featuresTitle span {
65 | display: inline-block;
66 | margin: 0 1rem;
67 | }
68 |
69 | @media screen and (max-width: 966px) {
70 | .featuresTitle span {
71 | display: block;
72 | margin: 1rem 0;
73 | }
74 | }
75 |
76 | .features h3 {
77 | font-size: 2rem;
78 | line-height: 4rem;
79 | margin: 1rem 0 2rem 0;
80 | font-weight: 800;
81 | }
82 |
83 | .features ul {
84 | list-style: none;
85 | text-align: center;
86 | padding: 0;
87 | }
88 |
89 | .features ul li {
90 | margin-top: 0.5rem;
91 | margin-bottom: 0.5rem;
92 | font-size: 1rem;
93 | white-space: nowrap;
94 | text-align: center;
95 | }
96 |
97 | .features ul li em {
98 | font-weight: 400;
99 | opacity: 0.8;
100 | }
101 |
102 | .featureImage {
103 | height: 220px;
104 | width: 220px;
105 | }
106 |
107 | .homeSubtitle {
108 | justify-content: center;
109 | padding: 0rem 0 2rem 0;
110 | opacity: 0.6;
111 | font-style: italic;
112 | margin: 0 auto;
113 | font-size: 1.2rem;
114 | text-align: center;
115 | }
116 |
--------------------------------------------------------------------------------
/src/pages/seo.js:
--------------------------------------------------------------------------------
1 | import React from "react"
2 | import Head from "@docusaurus/Head"
3 | import useDocusaurusContext from "@docusaurus/useDocusaurusContext"
4 |
5 | const Seo = () => {
6 | const context = useDocusaurusContext()
7 | const { siteConfig = {} } = context
8 | const { title, tagline, url } = siteConfig
9 |
10 | return (
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | )
24 | }
25 |
26 | export default Seo
27 |
--------------------------------------------------------------------------------
/static/googlecfaeef9e241b87bc.html:
--------------------------------------------------------------------------------
1 | google-site-verification: googlecfaeef9e241b87bc.html
--------------------------------------------------------------------------------
/static/img/brand-github-inverted.svg:
--------------------------------------------------------------------------------
1 |
2 |
5 |
--------------------------------------------------------------------------------
/static/img/brand-github.svg:
--------------------------------------------------------------------------------
1 |
2 |
5 |
--------------------------------------------------------------------------------
/static/img/brand-npm-inverted.svg:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/static/img/brand-npm.svg:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/static/img/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesstelford/docs/96814076ce398a25f0b18cd820d1e424b56bbed7/static/img/favicon-16x16.png
--------------------------------------------------------------------------------
/static/img/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesstelford/docs/96814076ce398a25f0b18cd820d1e424b56bbed7/static/img/favicon-32x32.png
--------------------------------------------------------------------------------
/static/img/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesstelford/docs/96814076ce398a25f0b18cd820d1e424b56bbed7/static/img/favicon.ico
--------------------------------------------------------------------------------
/static/img/logo/logo-sm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesstelford/docs/96814076ce398a25f0b18cd820d1e424b56bbed7/static/img/logo/logo-sm.png
--------------------------------------------------------------------------------
/static/img/logo/logo-xs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesstelford/docs/96814076ce398a25f0b18cd820d1e424b56bbed7/static/img/logo/logo-xs.png
--------------------------------------------------------------------------------
/static/img/logo/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesstelford/docs/96814076ce398a25f0b18cd820d1e424b56bbed7/static/img/logo/logo.png
--------------------------------------------------------------------------------
/static/img/mesh-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesstelford/docs/96814076ce398a25f0b18cd820d1e424b56bbed7/static/img/mesh-1.jpg
--------------------------------------------------------------------------------
/static/img/mesh-2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesstelford/docs/96814076ce398a25f0b18cd820d1e424b56bbed7/static/img/mesh-2.jpg
--------------------------------------------------------------------------------
/static/img/mesh-3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesstelford/docs/96814076ce398a25f0b18cd820d1e424b56bbed7/static/img/mesh-3.jpg
--------------------------------------------------------------------------------
/static/img/nextauth_v4_schema.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesstelford/docs/96814076ce398a25f0b18cd820d1e424b56bbed7/static/img/nextauth_v4_schema.png
--------------------------------------------------------------------------------
/static/img/nextjs-logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/img/pages_signin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesstelford/docs/96814076ce398a25f0b18cd820d1e424b56bbed7/static/img/pages_signin.png
--------------------------------------------------------------------------------
/static/img/pages_signout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesstelford/docs/96814076ce398a25f0b18cd820d1e424b56bbed7/static/img/pages_signout.png
--------------------------------------------------------------------------------
/static/img/providers/apple-black.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/static/img/providers/auth0.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/static/img/providers/aws-cognito.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/img/providers/box.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/img/providers/discord.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/img/providers/facebook-2.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/img/providers/github-1.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
--------------------------------------------------------------------------------
/static/img/providers/gitlab.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/img/providers/google-icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/img/providers/openid.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
45 |
--------------------------------------------------------------------------------
/static/img/providers/slack.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/img/providers/spotify.svg:
--------------------------------------------------------------------------------
1 |
2 |
5 |
--------------------------------------------------------------------------------
/static/img/providers/twitter.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/static/img/signin-complex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesstelford/docs/96814076ce398a25f0b18cd820d1e424b56bbed7/static/img/signin-complex.png
--------------------------------------------------------------------------------
/static/img/signin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesstelford/docs/96814076ce398a25f0b18cd820d1e424b56bbed7/static/img/signin.png
--------------------------------------------------------------------------------
/static/img/social-media-card.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesstelford/docs/96814076ce398a25f0b18cd820d1e424b56bbed7/static/img/social-media-card.png
--------------------------------------------------------------------------------
/vercel.json:
--------------------------------------------------------------------------------
1 | {
2 | "redirects": [
3 | {
4 | "source": "/schemas/models",
5 | "destination": "/adapters/models",
6 | "permanent": true
7 | },
8 | {
9 | "source": "/schemas/mysql",
10 | "destination": "/adapters/typeorm/mysql",
11 | "permanent": true
12 | },
13 | {
14 | "source": "/schemas/postgres",
15 | "destination": "/adapters/typeorm/postgres",
16 | "permanent": true
17 | },
18 | {
19 | "source": "/schemas/mssql",
20 | "destination": "/adapters/typeorm/mssql",
21 | "permanent": true
22 | },
23 | {
24 | "source": "/schemas/mongodb",
25 | "destination": "/adapters/typeorm/mongodb",
26 | "permanent": true
27 | },
28 | {
29 | "source": "/schemas/adapters",
30 | "destination": "/adapters/overview",
31 | "permanent": true
32 | }
33 | ]
34 | }
35 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/adapters/dynamodb.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: dynamodb
3 | title: DynamoDB Adapter
4 | ---
5 |
6 | # DynamoDB
7 |
8 | This is the AWS DynamoDB Adapter for next-auth. This package can only be used in conjunction with the primary next-auth package. It is not a standalone package.
9 |
10 | You need a table with a partition key `pk` and a sort key `sk`. Your table also needs a global secondary index named `GSI1` with `GSI1PK` as partition key and `GSI1SK` as sorting key. You can set whatever you want as the table name and the billing method.
11 |
12 | You can find the full schema in the table structure section below.
13 |
14 | ## Getting Started
15 |
16 | 1. Install `next-auth` and `@next-auth/dynamodb-adapter@canary`
17 |
18 | ```js
19 | npm install next-auth @next-auth/dynamodb-adapter@canary
20 | ```
21 |
22 | 2. Add this adapter to your `pages/api/auth/[...nextauth].js` next-auth configuration object.
23 |
24 | You need to pass `DocumentClient` instance from `aws-sdk` to the adapter.
25 | The default table name is `next-auth`, but you can customise that by passing `{ tableName: 'your-table-name' }` as the second parameter in the adapter.
26 |
27 | ```javascript title="pages/api/auth/[...nextauth].js"
28 | import AWS from "aws-sdk";
29 | import NextAuth from "next-auth";
30 | import Providers from "next-auth/providers";
31 | import { DynamoDBAdapter } from "@next-auth/dynamodb-adapter"
32 |
33 | AWS.config.update({
34 | accessKeyId: process.env.NEXT_AUTH_AWS_ACCESS_KEY,
35 | secretAccessKey: process.env.NEXT_AUTH_AWS_SECRET_KEY,
36 | region: process.env.NEXT_AUTH_AWS_REGION,
37 | });
38 |
39 | export default NextAuth({
40 | // Configure one or more authentication providers
41 | providers: [
42 | Providers.GitHub({
43 | clientId: process.env.GITHUB_ID,
44 | clientSecret: process.env.GITHUB_SECRET,
45 | }),
46 | Providers.Email({
47 | server: process.env.EMAIL_SERVER,
48 | from: process.env.EMAIL_FROM,
49 | }),
50 | // ...add more providers here
51 | ],
52 | adapter: DynamoDBAdapter(
53 | new AWS.DynamoDB.DocumentClient()
54 | ),
55 | ...
56 | });
57 | ```
58 |
59 | (AWS secrets start with `NEXT_AUTH_` in order to not conflict with [Vercel's reserved environment variables](https://vercel.com/docs/environment-variables#reserved-environment-variables).)
60 |
61 | ## Schema
62 |
63 | The table respects the single table design pattern. This has many advantages:
64 |
65 | - Only one table to manage, monitor and provision.
66 | - Querying relations is faster than with multi-table schemas (for eg. retrieving all sessions for a user).
67 | - Only one table needs to be replicated, if you want to go multi-region.
68 |
69 | Here is a schema of the table :
70 |
71 | 
72 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/adapters/fauna.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: fauna
3 | title: FaunaDB Adapter
4 | ---
5 |
6 | # FaunaDB
7 |
8 | This is the Fauna Adapter for [`next-auth`](https://next-auth.js.org). This package can only be used in conjunction with the primary `next-auth` package. It is not a standalone package.
9 |
10 | You can find the Fauna schema and seed information in the docs at [next-auth.js.org/adapters/fauna](https://next-auth.js.org/adapters/fauna).
11 |
12 | ## Getting Started
13 |
14 | 1. Install `next-auth` and `@next-auth/fauna-adapter@canary`
15 |
16 | ```js
17 | npm install next-auth @next-auth/fauna-adapter@canary
18 | ```
19 |
20 | 2. Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.
21 |
22 | ```javascript title="pages/api/auth/[...nextauth].js"
23 | import NextAuth from "next-auth"
24 | import Providers from "next-auth/providers"
25 | import * as Fauna from "faunadb"
26 | import { FaunaAdapter } from "@next-auth/fauna-adapter"
27 |
28 | const client = new Fauna.Client({
29 | secret: "secret",
30 | scheme: "http",
31 | domain: "localhost",
32 | port: 8443,
33 | })
34 |
35 | // For more information on each option (and a full list of options) go to
36 | // https://next-auth.js.org/configuration/options
37 | export default NextAuth({
38 | // https://next-auth.js.org/configuration/providers
39 | providers: [
40 | Providers.Google({
41 | clientId: process.env.GOOGLE_ID,
42 | clientSecret: process.env.GOOGLE_SECRET,
43 | }),
44 | ],
45 | adapter: FaunaAdapter({ faunaClient: client})
46 | ...
47 | })
48 | ```
49 |
50 | ## Schema
51 |
52 | ```javascript
53 | CreateCollection({ name: "accounts" })
54 | CreateCollection({ name: "sessions" })
55 | CreateCollection({ name: "users" })
56 | CreateCollection({ name: "verification_requests" })
57 | CreateIndex({
58 | name: "account_by_provider_account_id",
59 | source: Collection("accounts"),
60 | unique: true,
61 | terms: [
62 | { field: ["data", "providerId"] },
63 | { field: ["data", "providerAccountId"] },
64 | ],
65 | })
66 | CreateIndex({
67 | name: "session_by_token",
68 | source: Collection("sessions"),
69 | unique: true,
70 | terms: [{ field: ["data", "sessionToken"] }],
71 | })
72 | CreateIndex({
73 | name: "user_by_email",
74 | source: Collection("users"),
75 | unique: true,
76 | terms: [{ field: ["data", "email"] }],
77 | })
78 | CreateIndex({
79 | name: "verification_request_by_token",
80 | source: Collection("verification_requests"),
81 | unique: true,
82 | terms: [{ field: ["data", "token"] }, { field: ["data", "identifier"] }],
83 | })
84 | ```
85 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/adapters/models.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: models
3 | title: Models
4 | ---
5 |
6 | Models in NextAuth.js are built for ANSI SQL but are polymorphic and are transformed to adapt to the database being used; there is some variance in specific data types (e.g. for datetime, text fields, etc) but they are functionally the same with as much parity in behaviour as possible.
7 |
8 | All table/collection names in the built in models are plural, and all table names and column names use `snake_case` when used with an SQL database and `camelCase` when used with Document database.
9 |
10 | :::note
11 | You can [extend the built in models](/v3/tutorials/typeorm-custom-models) and even [create your own database adapter](/tutorials/creating-a-database-adapter) if you want to use NextAuth.js with a database that is not supported out of the box.
12 | :::
13 |
14 | ---
15 |
16 | ## User
17 |
18 | Table: `users`
19 |
20 | **Description:**
21 |
22 | The User model is for information such as the users name and email address.
23 |
24 | Email address are optional, but if one is specified for a User then it must be unique.
25 |
26 | :::note
27 | If a user first signs in with OAuth then their email address is automatically populated using the one from their OAuth profile, if the OAuth provider returns one.
28 |
29 | This provides a way to contact users and for users to maintain access to their account and sign in using email in the event they are unable to sign in with the OAuth provider in future (if email sign in is configured).
30 | :::
31 |
32 | ## Account
33 |
34 | Table: `accounts`
35 |
36 | **Description:**
37 |
38 | The Account model is for information about OAuth accounts associated with a User.
39 |
40 | A single User can have multiple Accounts, each Account can only have one User.
41 |
42 | ## Session
43 |
44 | Table: `sessions`
45 |
46 | **Description:**
47 |
48 | The Session model is used for database sessions. It is not used if JSON Web Tokens are enabled.
49 |
50 | A single User can have multiple Sessions, each Session can only have one User.
51 |
52 | ## Verification Request
53 |
54 | Table: `verification_requests`
55 |
56 | **Description:**
57 |
58 | The Verification Request model is used to store tokens for passwordless sign in emails.
59 |
60 | A single User can have multiple open Verification Requests (e.g. to sign in to different devices).
61 |
62 | It has been designed to be extendable for other verification purposes in future (e.g. 2FA / short codes).
63 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/adapters/overview.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: overview
3 | title: Overview
4 | ---
5 |
6 | An **Adapter** in NextAuth.js connects your application to whatever database or backend system you want to use to store data for user accounts, sessions, etc.
7 |
8 | The adapters can be found in their own repository under [`nextauthjs/adapters`](https://github.com/nextauthjs/adapters).
9 |
10 | There you can find the following adapters:
11 |
12 | - [`typeorm-legacy`](./typeorm/typeorm-overview)
13 | - [`prisma`](./prisma)
14 | - [`prisma-legacy`](./prisma-legacy)
15 | - [`fauna`](./fauna)
16 | - [`dynamodb`](./dynamodb)
17 | - [`firebase`](./firebase)
18 |
19 | ## Custom Adapter
20 |
21 | See the tutorial for [creating a database Adapter](/tutorials/creating-a-database-adapter) for more information on how to create a custom Adapter. Have a look at the [Adapter repository](https://github.com/nextauthjs/adapters) to see community maintained custom Adapter or add your own.
22 |
23 | ### Editor integration
24 |
25 | When writing your own custom Adapter in plain JavaScript, note that you can use **JSDoc** to get helpful editor hints and auto-completion like so:
26 |
27 | ```js
28 | /** @type { import("next-auth/adapters").Adapter } */
29 | const MyAdapter = () => {
30 | return {
31 | async getAdapter() {
32 | return {
33 | // your adapter methods here
34 | }
35 | },
36 | }
37 | }
38 | ```
39 |
40 | :::note
41 | This will work in code editors with a strong TypeScript integration like VSCode or WebStorm. It might not work if you're using more lightweight editors like VIM or Atom.
42 | :::
43 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/adapters/pouchdb.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: pouchdb
3 | title: PouchDB Adapter
4 | ---
5 |
6 | # PouchDB
7 |
8 | This is the PouchDB Adapter for [`next-auth`](https://next-auth.js.org). This package can only be used in conjunction with the primary `next-auth` package. It is not a standalone package.
9 |
10 | Depending on your architecture you can use PouchDB's http adapter to reach any database compliant with the CouchDB protocol (CouchDB, Cloudant, ...) or use any other PouchDB compatible adapter (leveldb, in-memory, ...)
11 |
12 | ## Getting Started
13 |
14 | > **Prerequesite**: Your PouchDB instance MUST provide the `pouchdb-find` plugin since it is used internally by the adapter to build and manage indexes
15 |
16 | 1. Install `next-auth` and `@next-auth/pouchdb-adapter@canary`
17 |
18 | ```js
19 | npm install next-auth @next-auth/pouchdb-adapter@canary
20 | ```
21 |
22 | 2. Add this adapter to your `pages/api/auth/[...nextauth].js` next-auth configuration object
23 |
24 | ```javascript title="pages/api/auth/[...nextauth].js"
25 | import NextAuth from "next-auth"
26 | import Providers from "next-auth/providers"
27 | import { PouchDBAdapter } from "@next-auth/pouchdb-adapter"
28 | import PouchDB from "pouchdb"
29 |
30 | // Setup your PouchDB instance and database
31 | PouchDB.plugin(require("pouchdb-adapter-leveldb")) // Any other adapter
32 | .plugin(require("pouchdb-find")) // Don't forget the `pouchdb-find` plugin
33 |
34 | const pouchdb = new PouchDB("auth_db", { adapter: "leveldb" })
35 |
36 | // For more information on each option (and a full list of options) go to
37 | // https://next-auth.js.org/configuration/options
38 | export default NextAuth({
39 | // https://next-auth.js.org/configuration/providers
40 | providers: [
41 | Providers.Google({
42 | clientId: process.env.GOOGLE_ID,
43 | clientSecret: process.env.GOOGLE_SECRET,
44 | }),
45 | ],
46 | adapter: PouchDBAdapter(pouchdb),
47 | // ...
48 | })
49 | ```
50 |
51 | ## Advanced
52 |
53 | ### Memory-First Caching Strategy
54 |
55 | If you need to boost your authentication layer performance, you may use PouchDB's powerful sync features and various adapters, to build a memory-first caching strategy.
56 |
57 | Use an in-memory PouchDB as your main authentication database, and synchronize it with any other persisted PouchDB. You may do a one way, one-off replication at startup from the persisted PouchDB into the in-memory PouchDB, then two-way, continuous, retriable sync.
58 |
59 | This will most likely not increase performance much in a serverless environment due to various reasons such as concurrency, function startup time increases, etc.
60 |
61 | For more details, please see https://pouchdb.com/api.html#sync
62 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/adapters/typeorm/mongodb.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: mongodb
3 | title: MongoDB
4 | ---
5 |
6 | MongoDB is a document database and does not use schemas in the same way as most RDBMS databases.
7 |
8 | **In MongoDB as collections and indexes are created automatically.**
9 |
10 | ## Objects in MongoDB
11 |
12 | Objects stored in MongoDB use similar datatypes to SQL, with some differences:
13 |
14 | 1. ID fields are of type `ObjectID` rather than type `int`.
15 |
16 | 2. All collection names and property names use `camelCase` rather than `snake_case`.
17 |
18 | 3. All timestamps are stored as `ISODate()` in MongoDB and all date/time values are stored in UTC.
19 |
20 | 4. A sparse index is used on the User `email` property to allow it to be optional, while still enforcing uniqueness if it is specified.
21 |
22 | This is functionally equivalent to the ANSI SQL behaviour for a `unique` but `nullable` property.
23 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/adapters/typeorm/overview.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: typeorm-overview
3 | title: Overview
4 | ---
5 |
6 | ## TypeORM Adapter
7 |
8 | NextAuth.js comes with a default Adapter that uses [TypeORM](https://typeorm.io/) so that it can be used with many different databases without any further configuration, you simply add the node module for the database driver you want to use in your project and pass a database connection string to NextAuth.js.
9 |
10 | ### Database Schemas
11 |
12 | Configure your database by creating the tables and columns to match the schema expected by NextAuth.js.
13 |
14 | - [MySQL Schema](./mysql)
15 | - [Postgres Schema](./postgres)
16 | - [Microsoft SQL Server Schema](./mssql)
17 | - [MongoDB](./mongodb)
18 |
19 | The default Adapter is the TypeORM Adapter and the default database type for TypeORM is SQLite, the following configuration options are exactly equivalent.
20 |
21 | ```javascript
22 | database: {
23 | type: 'sqlite',
24 | database: ':memory:',
25 | synchronize: true
26 | }
27 | ```
28 |
29 | ```javascript
30 | adapter: Adapters.Default({
31 | type: "sqlite",
32 | database: ":memory:",
33 | synchronize: true,
34 | })
35 | ```
36 |
37 | ```javascript
38 | adapter: Adapters.TypeORM.Adapter({
39 | type: "sqlite",
40 | database: ":memory:",
41 | synchronize: true,
42 | })
43 | ```
44 |
45 | The tutorial [Custom models with TypeORM](/v3/tutorials/typeorm-custom-models) explains how to extend the built in models and schemas used by the TypeORM Adapter. You can use these models in your own code.
46 |
47 | :::tip
48 | The `synchronize` option in TypeORM will generate SQL that exactly matches the documented schemas for MySQL and Postgres. This will automatically apply any changes it finds in the entity model, therefore it **should not be enabled against production databases** as it may cause data loss if the configured schema does not match the expected schema!
49 | :::
50 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/adapters/typeorm/postgres.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: postgres
3 | title: Postgres
4 | ---
5 |
6 | Schema for a Postgres database.
7 |
8 | :::note
9 | When using a Postgres database with the default adapter (TypeORM) all properties of type `timestamp` are transformed to `timestamp with time zone`/`timestamptz` and all timestamps are stored in UTC.
10 |
11 | This transform is also applied to any properties of type `timestamp` when using custom models.
12 | :::
13 |
14 | ```sql
15 | CREATE TABLE accounts
16 | (
17 | id SERIAL,
18 | compound_id VARCHAR(255) NOT NULL,
19 | user_id INTEGER NOT NULL,
20 | provider_type VARCHAR(255) NOT NULL,
21 | provider_id VARCHAR(255) NOT NULL,
22 | provider_account_id VARCHAR(255) NOT NULL,
23 | refresh_token TEXT,
24 | access_token TEXT,
25 | access_token_expires TIMESTAMPTZ,
26 | created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
27 | updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
28 | PRIMARY KEY (id)
29 | );
30 |
31 | CREATE TABLE sessions
32 | (
33 | id SERIAL,
34 | user_id INTEGER NOT NULL,
35 | expires TIMESTAMPTZ NOT NULL,
36 | session_token VARCHAR(255) NOT NULL,
37 | access_token VARCHAR(255) NOT NULL,
38 | created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
39 | updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
40 | PRIMARY KEY (id)
41 | );
42 |
43 | CREATE TABLE users
44 | (
45 | id SERIAL,
46 | name VARCHAR(255),
47 | email VARCHAR(255),
48 | email_verified TIMESTAMPTZ,
49 | image TEXT,
50 | created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
51 | updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
52 | PRIMARY KEY (id)
53 | );
54 |
55 | CREATE TABLE verification_requests
56 | (
57 | id SERIAL,
58 | identifier VARCHAR(255) NOT NULL,
59 | token VARCHAR(255) NOT NULL,
60 | expires TIMESTAMPTZ NOT NULL,
61 | created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
62 | updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
63 | PRIMARY KEY (id)
64 | );
65 |
66 | CREATE UNIQUE INDEX compound_id
67 | ON accounts(compound_id);
68 |
69 | CREATE INDEX provider_account_id
70 | ON accounts(provider_account_id);
71 |
72 | CREATE INDEX provider_id
73 | ON accounts(provider_id);
74 |
75 | CREATE INDEX user_id
76 | ON accounts(user_id);
77 |
78 | CREATE UNIQUE INDEX session_token
79 | ON sessions(session_token);
80 |
81 | CREATE UNIQUE INDEX access_token
82 | ON sessions(access_token);
83 |
84 | CREATE UNIQUE INDEX email
85 | ON users(email);
86 |
87 | CREATE UNIQUE INDEX token
88 | ON verification_requests(token);
89 |
90 | ```
91 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/configuration/events.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: events
3 | title: Events
4 | ---
5 |
6 | Events are asynchronous functions that do not return a response, they are useful for audit logs / reporting.
7 |
8 | You can specify a handler for any of these events below, for debugging or for an audit log.
9 |
10 | :::note
11 | Execution of your auth API will be blocked by an `await` on your event handler. If your event handler starts any burdensome work it should not block its own promise on that work.
12 | :::
13 |
14 | ## Events
15 |
16 | ### signIn
17 |
18 | Sent on successful sign in.
19 |
20 | The message will be an object and contain:
21 |
22 | - `user` (from your adapter or from the provider if a `credentials` type provider)
23 | - `account` (from your adapter or the provider)
24 | - `isNewUser` (whether your adapter had a user for this account already)
25 |
26 | ### signOut
27 |
28 | Sent when the user signs out.
29 |
30 | The message object is the JWT, if using them, or the adapter session object for the session that is being ended.
31 |
32 | ### createUser
33 |
34 | Sent when the adapter is told to create a new user.
35 |
36 | The message object will be the user.
37 |
38 | ### updateUser
39 |
40 | Sent when the adapter is told to update an existing user. Currently this is only sent when the user verifies their email address.
41 |
42 | The message object will be the user.
43 |
44 | ### linkAccount
45 |
46 | Sent when an account in a given provider is linked to a user in our userbase. For example, when a user signs up with Twitter or when an existing user links their Google account.
47 |
48 | The message will be an object and contain:
49 |
50 | - `user`: The user object from your adapter
51 | - `providerAccount`: The object returned from the provider.
52 |
53 | ### session
54 |
55 | Sent at the end of a request for the current session.
56 |
57 | The message will be an object and contain:
58 |
59 | - `session`: The session object from your adapter
60 | - `jwt`: If using JWT, the token for this session.
61 |
62 | ### error
63 |
64 | Sent when an error occurs
65 |
66 | The message could be any object relevant to describing the error.
67 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/contributors.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: contributors
3 | title: Contributors
4 | ---
5 |
6 | ## Core Team
7 |
8 | - [Iain Collins](https://github.com/iaincollins)
9 | - [Lori Karikari](https://github.com/LoriKarikari)
10 | - [Nico Domino](https://github.com/ndom91)
11 | - [Fredrik Pettersen](https://github.com/Fumler)
12 | - [Gerald Nolan](https://github.com/geraldnolan)
13 | - [Lluis Agusti](https://github.com/lluia)
14 | - [Jefferson Bledsoe](https://github.com/JeffersonBledsoe)
15 | - [Balázs Orbán](https://github.com/sponsors/balazsorban44)
16 |
17 | _Special thanks to Lori Karikari for creating most of the providers, to Nico Domino for creating this site, to Fredrik Pettersen for creating the Prisma adapter, to Gerald Nolan for adding support for Sign in with Apple, to Lluis Agusti for work to add TypeScript definitions and to Jefferson Bledsoe for working on automating testing._
18 |
19 | ## Other Contributors
20 |
21 | NextAuth.js as it exists today has been possible thanks to the work of many individual contributors.
22 |
23 | Thank you to the [dozens of individual contributors](https://github.com/nextauthjs/next-auth/graphs/contributors) who have help shaped NextAuth.js.
24 |
25 | ## History
26 |
27 | NextAuth.js was originally developed by Iain Collins in 2016.
28 |
29 | In 2020, NextAuth.js was rebuilt from the ground up to support Serverless, with support for MySQL, Postgres and MongoDB, JSON Web Tokens and built in support for over a dozen authentication providers.
30 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/getting-started/rest-api.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: rest-api
3 | title: REST API
4 | ---
5 |
6 | NextAuth.js exposes a REST API which is used by the NextAuth.js client.
7 |
8 | #### `GET` /api/auth/signin
9 |
10 | Displays the sign in page.
11 |
12 | #### `POST` /api/auth/signin/:provider
13 |
14 | Starts an OAuth signin flow for the specified provider.
15 |
16 | The POST submission requires CSRF token from `/api/auth/csrf`.
17 |
18 | #### `GET` /api/auth/callback/:provider
19 |
20 | Handles returning requests from OAuth services during sign in.
21 |
22 | For OAuth 2.0 providers that support the `state` option, the value of the `state` parameter is checked against the one that was generated when the sign in flow was started - this uses a hash of the CSRF token which MUST match for both the POST and `GET` calls during sign in.
23 |
24 | #### `GET` /api/auth/signout
25 |
26 | Displays the sign out page.
27 |
28 | #### `POST` /api/auth/signout
29 |
30 | Handles signing out - this is a `POST` submission to prevent malicious links from triggering signing a user out without their consent.
31 |
32 | The `POST` submission requires CSRF token from `/api/auth/csrf`.
33 |
34 | #### `GET` /api/auth/session
35 |
36 | Returns client-safe session object - or an empty object if there is no session.
37 |
38 | The contents of the session object that is returned are configurable with the session callback.
39 |
40 | #### `GET` /api/auth/csrf
41 |
42 | Returns object containing CSRF token. In NextAuth.js, CSRF protection is present on all authentication routes. It uses the "double submit cookie method", which uses a signed HttpOnly, host-only cookie.
43 |
44 | The CSRF token returned by this endpoint must be passed as form variable named `csrfToken` in all `POST` submissions to any API endpoint.
45 |
46 | #### `GET` /api/auth/providers
47 |
48 | Returns a list of configured OAuth services and details (e.g. sign in and callback URLs) for each service.
49 |
50 | It can be used to dynamically generate custom sign up pages and to check what callback URLs are configured for each OAuth provider that is configured.
51 |
52 | ---
53 |
54 | :::note
55 | The default base path is `/api/auth` but it is configurable by specifying a custom path in `NEXTAUTH_URL`
56 |
57 | e.g.
58 |
59 | `NEXTAUTH_URL=https://example.com/myapp/api/authentication`
60 |
61 | `/api/auth/signin` -> `/myapp/api/authentication/signin`
62 | :::
63 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/42.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: 42-school
3 | title: 42 School
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://api.intra.42.fr/apidoc/guides/web_application_flow
9 |
10 | ## Configuration
11 |
12 | https://profile.intra.42.fr/oauth/applications/new
13 |
14 | ## Options
15 |
16 | The **42 School Provider** comes with a set of default options:
17 |
18 | - [42 School Provider options](https://github.com/nextauthjs/next-auth/blob/ead715219a5d7a6e882a6ba27fa56b03954d062d/src/providers/42.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.FortyTwo({
29 | clientId: process.env.FORTY_TWO_CLIENT_ID,
30 | clientSecret: process.env.FORTY_TWO_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/atlassian.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: atlassian
3 | title: Atlassian
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developer.atlassian.com/cloud/jira/platform/oauth-2-authorization-code-grants-3lo-for-apps/#implementing-oauth-2-0--3lo-
9 |
10 | ## Options
11 |
12 | The **Atlassian Provider** comes with a set of default options:
13 |
14 | - [Atlassian Provider options](https://github.com/nextauthjs/next-auth/blob/ead715219a5d7a6e882a6ba27fa56b03954d062d/src/providers/atlassian.js)
15 |
16 | You can override any of the options to suit your own use case.
17 |
18 | ## Example
19 |
20 | ```js
21 | import Providers from `next-auth/providers`
22 | ...
23 | providers: [
24 | Providers.Atlassian({
25 | clientId: process.env.ATLASSIAN_CLIENT_ID,
26 | clientSecret: process.env.ATLASSIAN_CLIENT_SECRET,
27 | scope: 'write:jira-work read:jira-work read:jira-user offline_access read:me'
28 | })
29 | ]
30 | ...
31 | ```
32 |
33 | ## Instructions
34 |
35 | ### Configuration
36 |
37 | :::tip
38 | An app can be created at https://developer.atlassian.com/apps/
39 | :::
40 |
41 | Under "Apis and features" in the side menu, configure the following for "OAuth 2.0 (3LO)":
42 |
43 | - Redirect URL
44 | - http://localhost:3000/api/auth/callback/atlassian
45 |
46 | :::warning
47 | To enable access to Jira Platform REST API you must enable User Identity API and add `read:me` to your provider scope option.
48 | :::
49 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/auth0.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: auth0
3 | title: Auth0
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://auth0.com/docs/api/authentication#authorize-application
9 |
10 | ## Configuration
11 |
12 | https://manage.auth0.com/dashboard
13 |
14 | :::tip
15 | Configure your application in Auth0 as a 'Regular Web Application' (not a 'Single Page App').
16 | :::
17 |
18 | ## Options
19 |
20 | The **Auth0 Provider** comes with a set of default options:
21 |
22 | - [Auth0 Provider options](https://github.com/nextauthjs/next-auth/blob/ead715219a5d7a6e882a6ba27fa56b03954d062d/src/providers/auth0.js)
23 |
24 | You can override any of the options to suit your own use case.
25 |
26 | ## Example
27 |
28 | ```js
29 | import Providers from `next-auth/providers`
30 | ...
31 | providers: [
32 | Providers.Auth0({
33 | clientId: process.env.AUTH0_CLIENT_ID,
34 | clientSecret: process.env.AUTH0_CLIENT_SECRET,
35 | domain: process.env.AUTH0_DOMAIN
36 | })
37 | ]
38 | ...
39 | ```
40 |
41 | :::note
42 | `domain` should be the fully qualified domain – e.g. `dev-s6clz2lv.eu.auth0.com`
43 | :::
44 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/azure-ad-b2c.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: azure-ad-b2c
3 | title: Azure Active Directory B2C
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
9 |
10 | ## Configuration
11 |
12 | https://docs.microsoft.com/en-us/azure/active-directory-b2c/tutorial-create-tenant
13 |
14 | ## Options
15 |
16 | The **Azure Active Directory Provider** comes with a set of default options:
17 |
18 | - [Azure Active Directory Provider options](https://github.com/nextauthjs/next-auth/blob/ead715219a5d7a6e882a6ba27fa56b03954d062d/src/providers/azure-ad-b2c.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | - In https://portal.azure.com/ -> Azure Active Directory create a new App Registration.
25 | - Make sure to remember / copy
26 | - Application (client) ID
27 | - Directory (tenant) ID
28 | - When asked for a redirection URL, use http://localhost:3000/api/auth/callback/azure-ad-b2c
29 | - Create a new secret and remember / copy its value immediately, it will disappear.
30 |
31 | In `.env.local` create the following entries:
32 |
33 | ```
34 | AZURE_CLIENT_ID=
35 | AZURE_CLIENT_SECRET=
36 | AZURE_TENANT_ID=
37 | ```
38 |
39 | In `pages/api/auth/[...nextauth].js` find or add the AZURE entries:
40 |
41 | ```js
42 | import Providers from 'next-auth/providers';
43 | ...
44 | providers: [
45 | Providers.AzureADB2C({
46 | clientId: process.env.AZURE_CLIENT_ID,
47 | clientSecret: process.env.AZURE_CLIENT_SECRET,
48 | scope: 'offline_access User.Read',
49 | tenantId: process.env.AZURE_TENANT_ID,
50 | }),
51 | ]
52 | ...
53 |
54 | ```
55 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/basecamp.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: basecamp
3 | title: Basecamp
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://github.com/basecamp/api/blob/master/sections/authentication.md
9 |
10 | ## Configuration
11 |
12 | https://launchpad.37signals.com/integrations
13 |
14 | ## Options
15 |
16 | The **Basecamp Provider** comes with a set of default options:
17 |
18 | - [Basecamp Provider options](https://github.com/nextauthjs/next-auth/blob/ead715219a5d7a6e882a6ba27fa56b03954d062d/src/providers/basecamp.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Examples
23 |
24 | ### Basic profile information
25 |
26 | ```js
27 | import Providers from `next-auth/providers`
28 | ...
29 | providers: [
30 | Providers.Basecamp({
31 | clientId: process.env.BASECAMP_CLIENT_ID,
32 | clientSecret: process.env.BASECAMP_CLIENT_SECRET
33 | })
34 | ]
35 | ...
36 | ```
37 |
38 | :::note
39 | Using the example above, it is only possible to retrieve profile information such as account id, email and name. If you wish to retrieve user data in relation to a specific team, you must provide a different profileUrl and a custom function to handle profile information as shown in the example below.
40 | :::
41 |
42 | ### Profile information in relation to specific team
43 |
44 | ```js
45 | import Providers from `next-auth/providers`
46 | ...
47 | providers: [
48 | Providers.Basecamp({
49 | clientId: process.env.BASECAMP_CLIENT_ID,
50 | clientSecret: process.env.BASECAMP_CLIENT_SECRET,
51 | profileUrl: `https://3.basecampapi.com/${process.env.BASECAMP_TEAM_ID}/my/profile.json`,
52 | profile: (profile) => {
53 | return {
54 | id: profile.id,
55 | name: profile.name,
56 | email: profile.email_address,
57 | image: profile.avatar_url,
58 | admin: profile.admin,
59 | owner: profile.owner
60 | }
61 | }
62 | })
63 | ]
64 | ...
65 | ```
66 |
67 | :::tip
68 | The BASECAMP_TEAM_ID is found in the url path of your team's homepage. For example, if the url is `https://3.basecamp.com/1234567/projects`, then in this case the BASECAMP_TEAM_ID is 1234567
69 | :::
70 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/battlenet.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: battle.net
3 | title: Battle.net
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://develop.battle.net/documentation/guides/using-oauth
9 |
10 | ## Configuration
11 |
12 | https://develop.battle.net/access/clients
13 |
14 | ## Options
15 |
16 | The **Battle.net Provider** comes with a set of default options:
17 |
18 | - [Battle.net Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/battlenet.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.BattleNet({
29 | clientId: process.env.BATTLENET_CLIENT_ID,
30 | clientSecret: process.env.BATTLENET_CLIENT_SECRET,
31 | region: process.env.BATTLENET_REGION
32 | })
33 | ]
34 | ...
35 | ```
36 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/box.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: box
3 | title: Box
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developer.box.com/reference/
9 |
10 | ## Configuration
11 |
12 | https://developer.box.com/guides/sso-identities-and-app-users/connect-okta-to-app-users/configure-box/
13 |
14 | ## Options
15 |
16 | The **Box Provider** comes with a set of default options:
17 |
18 | - [Box Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/box.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.Box({
29 | clientId: process.env.BOX_CLIENT_ID,
30 | clientSecret: process.env.BOX_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/cognito.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: cognito
3 | title: Amazon Cognito
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-userpools-server-contract-reference.html
9 |
10 | ## Configuration
11 |
12 | https://console.aws.amazon.com/cognito/users/
13 |
14 | You need to select your AWS region to go the the Cognito dashboard.
15 |
16 | ## Options
17 |
18 | The **Amazon Cognito Provider** comes with a set of default options:
19 |
20 | - [Amazon Cognito Provider options](https://github.com/nextauthjs/next-auth/blob/ead715219a5d7a6e882a6ba27fa56b03954d062d/src/providers/cognito.js)
21 |
22 | You can override any of the options to suit your own use case.
23 |
24 | ## Example
25 |
26 | ```js
27 | import Providers from `next-auth/providers`
28 | ...
29 | providers: [
30 | Providers.Cognito({
31 | clientId: process.env.COGNITO_CLIENT_ID,
32 | clientSecret: process.env.COGNITO_CLIENT_SECRET,
33 | domain: process.env.COGNITO_DOMAIN,
34 | })
35 | ]
36 | ...
37 | ```
38 |
39 | :::warning
40 | Make sure you select all the appropriate client settings or the OAuth flow will not work.
41 | :::
42 |
43 | 
44 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/coinbase.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: coinbase
3 | title: Coinbase
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.coinbase.com/api/v2
9 |
10 | ## Configuration
11 |
12 | https://www.coinbase.com/settings/api
13 |
14 | ## Options
15 |
16 | The **Coinbase Provider** comes with a set of default options:
17 |
18 | - [Coinbase Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/coinbase.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.Coinbase({
29 | clientId: process.env.COINBASE_CLIENT_ID,
30 | clientSecret: process.env.COINBASE_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | :::tip
37 | This Provider template has a 2 hour access token to it. A refresh token is also returned.
38 | :::
39 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/discord.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: discord
3 | title: Discord
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://discord.com/developers/docs/topics/oauth2
9 |
10 | ## Configuration
11 |
12 | https://discord.com/developers/applications
13 |
14 | ## Options
15 |
16 | The **Discord Provider** comes with a set of default options:
17 |
18 | - [Discord Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/discord.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.Discord({
29 | clientId: process.env.DISCORD_CLIENT_ID,
30 | clientSecret: process.env.DISCORD_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/dropbox.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: dropbox
3 | title: Dropbox
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.dropbox.com/oauth-guide
9 |
10 | ## Configuration
11 |
12 | https://www.dropbox.com/developers/apps
13 |
14 | ## Options
15 |
16 | The **Dropbox Provider** comes with a set of default options:
17 |
18 | - [Dropbox Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/dropbox.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.Dropbox({
29 | clientId: process.env.DROPBOX_CLIENT_ID,
30 | clientSecret: process.env.DROPBOX_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/eveonline.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: eveonline
3 | title: EVE Online
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.eveonline.com/blog/article/sso-to-authenticated-calls
9 |
10 | ## Configuration
11 |
12 | https://developers.eveonline.com/
13 |
14 | ## Options
15 |
16 | The **EVE Online Provider** comes with a set of default options:
17 |
18 | - [EVE Online Provider options](https://github.com/nextauthjs/next-auth/blob/ead715219a5d7a6e882a6ba27fa56b03954d062d/src/providers/eveonline.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.EVEOnline({
29 | clientId: process.env.EVE_CLIENT_ID,
30 | clientSecret: process.env.EVE_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | :::tip When creating your application, make sure to select `Authentication Only` as the connection type.
37 |
38 | :::tip If using JWT for the session, you can add the `CharacterID` to the JWT token and session. Example:
39 |
40 | ```js
41 | ...
42 | options: {
43 | jwt: {
44 | secret: process.env.JWT_SECRET,
45 | },
46 | callbacks: {
47 | jwt: async (token, user, account, profile, isNewUser) => {
48 | if (profile) {
49 | token = {
50 | ...token,
51 | id: profile.CharacterID,
52 | }
53 | }
54 | return token;
55 | },
56 | session: async (session, token) => {
57 | if (token) {
58 | session.user.id = token.id;
59 | }
60 | return session;
61 | }
62 | }
63 | }
64 | ...
65 | ```
66 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/facebook.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: facebook
3 | title: Facebook
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/
9 |
10 | ## Configuration
11 |
12 | https://developers.facebook.com/apps/
13 |
14 | ## Options
15 |
16 | The **Facebook Provider** comes with a set of default options:
17 |
18 | - [Facebook Provider options](https://github.com/nextauthjs/next-auth/blob/ead715219a5d7a6e882a6ba27fa56b03954d062d/src/providers/facebook.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.Facebook({
29 | clientId: process.env.FACEBOOK_CLIENT_ID,
30 | clientSecret: process.env.FACEBOOK_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | :::tip
37 | Production applications cannot use localhost URLs to sign in with Facebook. You need to use a dedicated development application in Facebook to use **localhost** callback URLs.
38 | :::
39 |
40 | :::tip
41 | Email address may not be returned for accounts created on mobile.
42 | :::
43 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/faceit.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: faceit
3 | title: FACEIT
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://cdn.faceit.com/third_party/docs/FACEIT_Connect_3.0.pdf
9 |
10 | ## Configuration
11 |
12 | https://developers.faceit.com/apps
13 |
14 | Grant type: `Authorization Code`
15 |
16 | Scopes to have basic infos (email, nickname, guid and avatar) : `openid`, `email`, `profile`
17 |
18 | ## Options
19 |
20 | The **FACEIT Provider** comes with a set of default options:
21 |
22 | - [FACEIT Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/faceit.js)
23 |
24 | You can override any of the options to suit your own use case.
25 |
26 | ## Example
27 |
28 | ```js
29 | import Providers from `next-auth/providers`
30 | ...
31 | providers: [
32 | Providers.FACEIT({
33 | clientId: process.env.FACEIT_CLIENT_ID,
34 | clientSecret: process.env.FACEIT_CLIENT_SECRET
35 | })
36 | ]
37 | ...
38 | ```
39 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/foursquare.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: foursquare
3 | title: Foursquare
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developer.foursquare.com/docs/places-api/authentication/#web-applications
9 |
10 | ## Configuration
11 |
12 | https://developer.foursquare.com/
13 |
14 | :::warning
15 | Foursquare requires an additional `apiVersion` parameter in [`YYYYMMDD` format](https://developer.foursquare.com/docs/places-api/versioning/), which essentially states "I'm prepared for API changes up to this date".
16 |
17 | ## Options
18 |
19 | The **Foursquare Provider** comes with a set of default options:
20 |
21 | - [Foursquare Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/foursquare.js)
22 |
23 | You can override any of the options to suit your own use case.
24 |
25 | ## Example
26 |
27 | ```js
28 | import Providers from `next-auth/providers`
29 | ...
30 | providers: [
31 | Providers.Foursquare({
32 | clientId: process.env.FOURSQUARE_CLIENT_ID,
33 | clientSecret: process.env.FOURSQUARE_CLIENT_SECRET,
34 | apiVersion: 'YYYYMMDD'
35 | })
36 | ]
37 | ...
38 | ```
39 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/fusionauth.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: fusionauth
3 | title: FusionAuth
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://fusionauth.io/docs/v1/tech/oauth/
9 |
10 | ## Options
11 |
12 | The **FusionAuth Provider** comes with a set of default options:
13 |
14 | - [FusionAuth Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/fusionauth.js)
15 |
16 | You can override any of the options to suit your own use case.
17 |
18 | ## Example
19 |
20 | ```js
21 | import Providers from `next-auth/providers`
22 | ...
23 | providers: [
24 | Providers.FusionAuth({
25 | id: "fusionauth",
26 | name: "FusionAuth",
27 | domain: process.env.FUSIONAUTH_DOMAIN,
28 | clientId: process.env.FUSIONAUTH_CLIENT_ID,
29 | clientSecret: process.env.FUSIONAUTH_SECRET,
30 | tenantId: process.env.FUSIONAUTH_TENANT_ID // Only required if you're using multi-tenancy
31 | }),
32 | ]
33 | ...
34 | ```
35 |
36 | :::warning
37 | If you're using multi-tenancy, you need to pass in the `tenantId` option to apply the proper theme.
38 | :::
39 |
40 | ## Instructions
41 |
42 | ### Configuration
43 |
44 | :::tip
45 | An application can be created at https://your-fusionauth-server-url/admin/application.
46 |
47 | For more information, follow the [FusionAuth 5-minute setup guide](https://fusionauth.io/docs/v1/tech/5-minute-setup-guide).
48 | :::
49 |
50 | In the OAuth settings for your application, configure the following.
51 |
52 | - Redirect URL
53 | - https://localhost:3000/api/auth/callback/fusionauth
54 | - Enabled grants
55 | - Make sure _Authorization Code_ is enabled.
56 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/github.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: github
3 | title: GitHub
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps
9 |
10 | ## Configuration
11 |
12 | https://github.com/settings/apps
13 |
14 | ## Options
15 |
16 | The **Github Provider** comes with a set of default options:
17 |
18 | - [Github Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/github.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.GitHub({
29 | clientId: process.env.GITHUB_CLIENT_ID,
30 | clientSecret: process.env.GITHUB_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | :::warning
37 | Only allows one callback URL per Client ID / Client Secret.
38 | :::
39 |
40 | :::tip
41 | Email address is not returned if privacy settings are enabled.
42 | :::
43 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/gitlab.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: gitlab
3 | title: GitLab
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://docs.gitlab.com/ee/api/oauth2.html
9 |
10 | ## Configuration
11 |
12 | https://gitlab.com/profile/applications
13 |
14 | ## Options
15 |
16 | The **Gitlab Provider** comes with a set of default options:
17 |
18 | - [Gitlab Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/gitlab.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.GitLab({
29 | clientId: process.env.GITLAB_CLIENT_ID,
30 | clientSecret: process.env.GITLAB_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | :::tip
37 | Enable the _"read_user"_ option in scope if you want to save the users email address on sign up.
38 | :::
39 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/google.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: google
3 | title: Google
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.google.com/identity/protocols/oauth2
9 |
10 | ## Configuration
11 |
12 | https://console.developers.google.com/apis/credentials
13 |
14 | ## Options
15 |
16 | The **Google Provider** comes with a set of default options:
17 |
18 | - [Google Provider options](https://github.com/nextauthjs/next-auth/blob/ead715219a5d7a6e882a6ba27fa56b03954d062d/src/providers/google.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.Google({
29 | clientId: process.env.GOOGLE_CLIENT_ID,
30 | clientSecret: process.env.GOOGLE_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | :::warning
37 | Google only provide the Refresh Token to an application the first time a user signs in.
38 |
39 | To force Google to re-issue a Refresh Token, the user needs to remove the application from their account and sign in again:
40 | https://myaccount.google.com/permissions
41 |
42 | Alternatively, you can also pass options in the `authorizationUrl` which will force the Refresh Token to always be provided on sign in, however this will ask all users to confirm if they wish to grant your application access every time they sign in.
43 |
44 | If you need access to the RefreshToken or AccessToken for a Google account and you are not using a database to persist user accounts, this may be something you need to do.
45 |
46 | ```js
47 | const options = {
48 | ...
49 | providers: [
50 | Providers.Google({
51 | clientId: process.env.GOOGLE_ID,
52 | clientSecret: process.env.GOOGLE_SECRET,
53 | authorizationUrl: 'https://accounts.google.com/o/oauth2/v2/auth?prompt=consent&access_type=offline&response_type=code',
54 | })
55 | ],
56 | ...
57 | }
58 | ```
59 |
60 | :::
61 |
62 | :::tip
63 | Google also return an `verified_email` boolean property in the OAuth profile.
64 |
65 | You can use this property to restrict access to people with verified accounts at a particular domain.
66 |
67 | ```js
68 | const options = {
69 | ...
70 | callbacks: {
71 | async signIn(user, account, profile) {
72 | if (account.provider === 'google' &&
73 | profile.verified_email === true &&
74 | profile.email.endsWith('@example.com')) {
75 | return true
76 | } else {
77 | return false
78 | }
79 | },
80 | }
81 | ...
82 | }
83 | ```
84 |
85 | :::
86 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/identity-server4.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: identity-server4
3 | title: IdentityServer4
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://identityserver4.readthedocs.io/en/latest/
9 |
10 | ## Options
11 |
12 | The **IdentityServer4 Provider** comes with a set of default options:
13 |
14 | - [IdentityServer4 Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/identity-server4.js)
15 |
16 | You can override any of the options to suit your own use case.
17 |
18 | ## Example
19 |
20 | ```js
21 | import Providers from `next-auth/providers`
22 | ...
23 | providers: [
24 | Providers.IdentityServer4({
25 | id: "identity-server4",
26 | name: "IdentityServer4",
27 | scope: "openid profile email api offline_access", // Allowed Scopes
28 | domain: process.env.IdentityServer4_Domain,
29 | clientId: process.env.IdentityServer4_CLIENT_ID,
30 | clientSecret: process.env.IdentityServer4_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | ## Demo IdentityServer
37 |
38 | The configuration below is for the demo server at https://demo.identityserver.io/
39 |
40 | If you want to try it out, you can copy and paste the configuration below.
41 |
42 | You can sign in to the demo service with either bob/bob or alice/alice.
43 |
44 | ```js
45 | import Providers from `next-auth/providers`
46 | ...
47 | providers: [
48 | Providers.IdentityServer4({
49 | id: "demo-identity-server",
50 | name: "Demo IdentityServer4",
51 | scope: "openid profile email api offline_access",
52 | domain: "demo.identityserver.io",
53 | clientId: "interactive.confidential",
54 | clientSecret: "secret",
55 | protection: "pkce"
56 | })
57 | }
58 | ...
59 | ```
60 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/instagram.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: instagram
3 | title: Instagram
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.facebook.com/docs/instagram-basic-display-api/getting-started
9 |
10 | ## Configuration
11 |
12 | https://developers.facebook.com/apps/
13 |
14 | ## Options
15 |
16 | The **Instagram Provider** comes with a set of default options:
17 |
18 | - [Instagram Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/instagram.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```jsx
25 | // pages/api/auth/[...nextauth].js
26 | import Providers from `next-auth/providers`
27 | ...
28 | providers: [
29 | Providers.Instagram({
30 | clientId: process.env.INSTAGRAM_CLIENT_ID,
31 | clientSecret: process.env.INSTAGRAM_CLIENT_SECRET
32 | })
33 | ]
34 | ...
35 | // pages/index.jsx
36 | import { signIn } from "next-auth/client"
37 | ...
38 |
41 | ...
42 | ```
43 |
44 | :::warning
45 | Email address is not returned by the Instagram API.
46 | :::
47 |
48 | :::tip
49 | Instagram display app required callback URL to be configured in your Facebook app and Facebook required you to use **https** even for localhost! In order to do that, you either need to [add an SSL to your localhost](https://www.freecodecamp.org/news/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec/) or use a proxy such as [ngrok](https://ngrok.com/docs).
50 | :::
51 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/kakao.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: kakao
3 | title: Kakao
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.kakao.com/product/kakaoLogin
9 |
10 | ## Configuration
11 |
12 | https://developers.kakao.com/docs/latest/en/kakaologin/common
13 |
14 | ## Options
15 |
16 | The **Kakao Provider** comes with a set of default options:
17 |
18 | - [Kakao Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/kakao.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.Kakao({
29 | clientId: process.env.KAKAO_CLIENT_ID,
30 | clientSecret: process.env.KAKAO_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | ## Instructions
37 |
38 | ### Configuration
39 |
40 | Create a provider and a Kakao application at `https://developers.kakao.com/console/app`. In the settings of the app under Kakao Login, activate web app, change consent items and configure callback URL.
41 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/line.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: line
3 | title: LINE
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.line.biz/en/docs/line-login/integrate-line-login/
9 |
10 | ## Configuration
11 |
12 | https://developers.line.biz/console/
13 |
14 | ## Options
15 |
16 | The **Line Provider** comes with a set of default options:
17 |
18 | - [Line Provider options](https://github.com/nextauthjs/next-auth/blob/ead715219a5d7a6e882a6ba27fa56b03954d062d/src/providers/line.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.LINE({
29 | clientId: process.env.LINE_CLIENT_ID,
30 | clientSecret: process.env.LINE_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | ## Instructions
37 |
38 | ### Configuration
39 |
40 | Create a provider and a LINE login channel at `https://developers.line.biz/console/`. In the settings of the channel under LINE Login, activate web app and configure the following:
41 |
42 | - Callback URL
43 | - http://localhost:3000/api/auth/callback/line
44 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/linkedin.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: linkedin
3 | title: LinkedIn
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://docs.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow
9 |
10 | ## Configuration
11 |
12 | https://www.linkedin.com/developers/apps/
13 |
14 | From the Auth tab get the client ID and client secret. On the same tab, add redirect URLs such as http://localhost:3000/api/auth/callback/linkedin so LinkedIn can correctly redirect back to your application. Finally, head over to the Products tab and enable the "Sign In with LinkedIn" product. The LinkedIn team will review and approve your request before you can test it out.
15 |
16 | 
17 |
18 | ## Options
19 |
20 | The **LinkedIn Provider** comes with a set of default options:
21 |
22 | - [LinkedIn Provider options](https://github.com/nextauthjs/next-auth/blob/ead715219a5d7a6e882a6ba27fa56b03954d062d/src/providers/linkedin.js)
23 |
24 | You can override any of the options to suit your own use case.
25 |
26 | ## Example
27 |
28 | ```js
29 | import Providers from `next-auth/providers`
30 | ...
31 | providers: [
32 | Providers.LinkedIn({
33 | clientId: process.env.LINKEDIN_CLIENT_ID,
34 | clientSecret: process.env.LINKEDIN_CLIENT_SECRET
35 | })
36 | ]
37 | ...
38 | ```
39 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/mailchimp.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: mailchimp
3 | title: Mailchimp
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://mailchimp.com/developer/marketing/guides/access-user-data-oauth-2/
9 |
10 | ## Configuration
11 |
12 | https://admin.mailchimp.com/account/oauth2/client/
13 |
14 | ## Options
15 |
16 | The **Mailchimp Provider** comes with a set of default options:
17 |
18 | - [Mailchimp Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/mailchimp.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.Mailchimp({
29 | clientId: process.env.MAILCHIMP_CLIENT_ID,
30 | clientSecret: process.env.MAILCHIMP_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/mailru.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: mailru
3 | title: Mail.ru
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://o2.mail.ru/docs
9 |
10 | ## Configuration
11 |
12 | https://o2.mail.ru/app/
13 |
14 | ## Options
15 |
16 | The **Mail.ru Provider** comes with a set of default options:
17 |
18 | - [Mail.ru Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/mailru.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.MailRu({
29 | clientId: process.env.MAILRU_CLIENT_ID,
30 | clientSecret: process.env.MAILRU_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/medium.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: medium
3 | title: Medium
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://github.com/Medium/medium-api-docs
9 |
10 | ## Configuration
11 |
12 | https://medium.com/me/applications
13 |
14 | ## Options
15 |
16 | The **Medium Provider** comes with a set of default options:
17 |
18 | - [Medium Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/medium.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.Medium({
29 | clientId: process.env.MEDIUM_CLIENT_ID,
30 | clientSecret: process.env.MEDIUM_CLIENT_SECRET
31 | })
32 | }
33 | ...
34 | ```
35 |
36 | :::warning
37 | Email address is not returned by the Medium API.
38 | :::
39 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/naver.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: naver
3 | title: Naver
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developers.naver.com/docs/login/overview/overview.md
9 |
10 | ## Configuration
11 |
12 | https://developers.naver.com/docs/login/api/api.md
13 |
14 | ## Options
15 |
16 | The **Naver Provider** comes with a set of default options:
17 |
18 | - [Naver Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/naver.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.Naver({
29 | clientId: process.env.NAVER_CLIENT_ID,
30 | clientSecret: process.env.NAVER_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/netlify.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: netlify
3 | title: Netlify
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://www.netlify.com/blog/2016/10/10/integrating-with-netlify-oauth2/
9 |
10 | ## Configuration
11 |
12 | https://github.com/netlify/netlify-oauth-example
13 |
14 | ## Options
15 |
16 | The **Netlify Provider** comes with a set of default options:
17 |
18 | - [Netlify Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/netlify.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.Netlify({
29 | clientId: process.env.NETLIFY_CLIENT_ID,
30 | clientSecret: process.env.NETLIFY_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/okta.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: okta
3 | title: Okta
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developer.okta.com/docs/reference/api/oidc
9 |
10 | ## Options
11 |
12 | The **Okta Provider** comes with a set of default options:
13 |
14 | - [Okta Provider options](https://github.com/nextauthjs/next-auth/blob/ead715219a5d7a6e882a6ba27fa56b03954d062d/src/providers/okta.js)
15 |
16 | You can override any of the options to suit your own use case.
17 |
18 | ## Example
19 |
20 | ```js
21 | import Providers from `next-auth/providers`
22 | ...
23 | providers: [
24 | Providers.Okta({
25 | clientId: process.env.OKTA_CLIENT_ID,
26 | clientSecret: process.env.OKTA_CLIENT_SECRET,
27 | domain: process.env.OKTA_DOMAIN
28 | })
29 | ]
30 | ...
31 | ```
32 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/osso.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: osso
3 | title: Osso
4 | ---
5 |
6 | ## Documentation
7 |
8 | Osso is an open source service that handles SAML authentication against Identity Providers, normalizes profiles, and makes those profiles available to you in an OAuth 2.0 code grant flow.
9 |
10 | If you don't yet have an Osso instance, you can use [Osso's Demo App](https://demo.ossoapp.com) for your testing purposes. For documentation on deploying an Osso instance, see https://ossoapp.com/docs/deploy/overview/
11 |
12 | ## Configuration
13 |
14 | You can configure your OAuth Clients on your Osso Admin UI, i.e. https://demo.ossoapp.com/admin/config - you'll need to get a Client ID and Secret and allow-list your redirect URIs.
15 |
16 | [SAML SSO differs a bit from OAuth](https://ossoapp.com/blog/saml-vs-oauth) - for every tenant who wants to sign in to your application using SAML, you and your customer need to perform a multi-step configuration in Osso's Admin UI and the admin dashboard of the tenant's Identity Provider. Osso provides documentation for providers like Okta and OneLogin, cloud-based IDPs who also offer a developer account that's useful for testing. Osso also provides a [Mock IDP](https://idp.ossoapp.com) that you can use for testing without needing to sign up for an Identity Provider service.
17 |
18 | See Osso's complete configuration and testing documentation at https://ossoapp.com/docs/configure/overview
19 |
20 | ## Options
21 |
22 | The **Osso Provider** comes with a set of default options:
23 |
24 | - [Osso Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/osso.js)
25 |
26 | You can override any of the options to suit your own use case.
27 |
28 | ## Example
29 |
30 | A full example application is available at https://github.com/enterprise-oss/osso-next-auth-example and https://nextjs-demo.ossoapp.com
31 |
32 | ```js
33 | import Providers from `next-auth/providers`
34 | ...
35 | providers: [
36 | Providers.Osso({
37 | clientId: process.env.OSSO_CLIENT_ID,
38 | clientSecret: process.env.OSSO_CLIENT_SECRET,
39 | domain: process.env.OSSO_DOMAIN
40 | })
41 | }
42 | ...
43 | ```
44 |
45 | :::note
46 | `domain` should be the fully qualified domain – e.g. `demo.ossoapp.com`
47 | :::
48 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/reddit.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: reddit
3 | title: Reddit
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://www.reddit.com/dev/api/
9 |
10 | ## Configuration
11 |
12 | https://www.reddit.com/prefs/apps/
13 |
14 | ## Options
15 |
16 | The **Reddit Provider** comes with a set of default options:
17 |
18 | - [Reddit Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/reddit.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.Reddit({
29 | clientId: process.env.REDDIT_CLIENT_ID,
30 | clientSecret: process.env.REDDIT_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | :::warning
37 | Reddit requires authorization every time you go through their page.
38 | :::
39 |
40 | :::warning
41 | Only allows one callback URL per Client ID / Client Secret.
42 | :::
43 |
44 | :::tip
45 | This Provider template only has a one hour access token to it and only has the 'identity' scope. If you want to get a refresh token as well you must follow this:
46 |
47 | ```js
48 | providers: [
49 | {
50 | id: "reddit",
51 | name: "Reddit",
52 | clientId: process.env.REDDIT_CLIENT_ID,
53 | clientSecret: process.env.REDDIT_CLIENT_SECRET,
54 | scope: "identity mysubreddits read", //Check Reddit API Documentation for more. The identity scope is required.
55 | type: "oauth",
56 | version: "2.0",
57 | params: { grant_type: "authorization_code" },
58 | accessTokenUrl: " https://www.reddit.com/api/v1/access_token",
59 | authorizationUrl:
60 | "https://www.reddit.com/api/v1/authorize?response_type=code&duration=permanent",
61 | profileUrl: "https://oauth.reddit.com/api/v1/me",
62 | profile: (profile) => {
63 | return {
64 | id: profile.id,
65 | name: profile.name,
66 | email: null,
67 | }
68 | },
69 | },
70 | ]
71 | ```
72 |
73 | :::
74 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/salesforce.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: salesforce
3 | title: Salesforce
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://help.salesforce.com/articleView?id=remoteaccess_authenticate.htm&type=5
9 |
10 | ## Options
11 |
12 | The **Salesforce Provider** comes with a set of default options:
13 |
14 | - [Salesforce Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/salesforce.js)
15 |
16 | You can override any of the options to suit your own use case.
17 |
18 | ## Example
19 |
20 | ```js
21 | import Providers from `next-auth/providers`
22 | ...
23 | providers: [
24 | Providers.Salesforce({
25 | clientId: process.env.SALESFORCE_CLIENT_ID,
26 | clientSecret: process.env.SALESFORCE_CLIENT_SECRET,
27 | })
28 | ]
29 | ...
30 | ```
31 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/slack.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: slack
3 | title: Slack
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://api.slack.com/authentication
9 | https://api.slack.com/docs/sign-in-with-slack
10 |
11 | ## Configuration
12 |
13 | https://api.slack.com/apps
14 |
15 | ## Options
16 |
17 | The **Slack Provider** comes with a set of default options:
18 |
19 | - [Slack Provider options](https://github.com/nextauthjs/next-auth/blob/ead715219a5d7a6e882a6ba27fa56b03954d062d/src/providers/slack.js)
20 |
21 | You can override any of the options to suit your own use case.
22 |
23 | ## Example
24 |
25 | ```js
26 | import Providers from `next-auth/providers`
27 | ...
28 | providers: [
29 | Providers.Slack({
30 | clientId: process.env.SLACK_CLIENT_ID,
31 | clientSecret: process.env.SLACK_CLIENT_SECRET
32 | })
33 | ]
34 | ...
35 | ```
36 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/spotify.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: spotify
3 | title: Spotify
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developer.spotify.com/documentation
9 |
10 | ## Configuration
11 |
12 | https://developer.spotify.com/dashboard/applications
13 |
14 | ## Options
15 |
16 | The **Spotify Provider** comes with a set of default options:
17 |
18 | - [Spotify Provider options](https://github.com/nextauthjs/next-auth/blob/ead715219a5d7a6e882a6ba27fa56b03954d062d/src/providers/spotify.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.Spotify({
29 | clientId: process.env.SPOTIFY_CLIENT_ID,
30 | clientSecret: process.env.SPOTIFY_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/strava.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: strava
3 | title: Strava
4 | ---
5 |
6 | ## Documentation
7 |
8 | http://developers.strava.com/docs/reference/
9 |
10 | ## Options
11 |
12 | The **Strava Provider** comes with a set of default options:
13 |
14 | - [Strava Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/strava.js)
15 |
16 | You can override any of the options to suit your own use case.
17 |
18 | ## Example
19 |
20 | ```js
21 | import Providers from 'next-auth/providers'
22 | ...
23 | providers: [
24 | Providers.Strava({
25 | clientId: process.env.STRAVA_CLIENT_ID,
26 | clientSecret: process.env.STRAVA_CLIENT_SECRET,
27 | })
28 | ]
29 | ...
30 | ```
31 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/twitch.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: twitch
3 | title: Twitch
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://dev.twitch.tv/docs/authentication
9 |
10 | ## Configuration
11 |
12 | https://dev.twitch.tv/console/apps
13 |
14 | Add the following redirect URL into the console `http:///api/auth/callback/twitch`
15 |
16 | ## Options
17 |
18 | The **Twitch Provider** comes with a set of default options:
19 |
20 | - [Twitch Provider options](https://github.com/nextauthjs/next-auth/blob/ead715219a5d7a6e882a6ba27fa56b03954d062d/src/providers/twitch.js)
21 |
22 | You can override any of the options to suit your own use case.
23 |
24 | ## Example
25 |
26 | ```js
27 | import Providers from `next-auth/providers`
28 | ...
29 | providers: [
30 | Providers.Twitch({
31 | clientId: process.env.TWITCH_CLIENT_ID,
32 | clientSecret: process.env.TWITCH_CLIENT_SECRET
33 | })
34 | ]
35 | ...
36 | ```
37 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/twitter.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: twitter
3 | title: Twitter
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developer.twitter.com
9 |
10 | ## Configuration
11 |
12 | https://developer.twitter.com/en/apps
13 |
14 | ## Options
15 |
16 | The **Twitter Provider** comes with a set of default options:
17 |
18 | - [Twitter Provider options](https://github.com/nextauthjs/next-auth/blob/ead715219a5d7a6e882a6ba27fa56b03954d062d/src/providers/twitter.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.Twitter({
29 | clientId: process.env.TWITTER_CLIENT_ID,
30 | clientSecret: process.env.TWITTER_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | :::tip
37 | You must enable the _"Request email address from users"_ option in your app permissions if you want to obtain the users email address.
38 | :::
39 |
40 | 
41 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/vk.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: vk
3 | title: VK
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://vk.com/dev/first_guide
9 |
10 | ## Configuration
11 |
12 | https://vk.com/apps?act=manage
13 |
14 | ## Options
15 |
16 | The **VK Provider** comes with a set of default options:
17 |
18 | - [VK Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/vk.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.VK({
29 | clientId: process.env.VK_CLIENT_ID,
30 | clientSecret: process.env.VK_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
36 | :::note
37 | By default the provider uses `5.126` version of the API. See https://vk.com/dev/versions for more info.
38 | :::
39 |
40 | If you want to use a different version, you can pass it to provider's options object:
41 |
42 | ```js
43 | // pages/api/auth/[...nextauth].js
44 |
45 | const apiVersion = "5.126"
46 | ...
47 | providers: [
48 | Providers.VK({
49 | accessTokenUrl: `https://oauth.vk.com/access_token?v=${apiVersion}`,
50 | requestTokenUrl: `https://oauth.vk.com/access_token?v=${apiVersion}`,
51 | authorizationUrl:
52 | `https://oauth.vk.com/authorize?response_type=code&v=${apiVersion}`,
53 | profileUrl: `https://api.vk.com/method/users.get?fields=photo_100&v=${apiVersion}`,
54 | })
55 | ]
56 | ...
57 | ```
58 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/wordpress.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: wordpress
3 | title: WordPress.com
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://developer.wordpress.com/docs/oauth2/
9 |
10 | ## Configuration
11 |
12 | https://developer.wordpress.com/apps/
13 |
14 | ## Options
15 |
16 | The **Wordpress Provider** comes with a set of default options:
17 |
18 | - [Wordpress Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/wordpress.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.WordPress({
29 | clientId: process.env.WORDPRESS_CLIENT_ID,
30 | clientSecret: process.env.WORDPRESS_CLIENT_SECRET
31 | })
32 | }
33 | ...
34 | ```
35 |
36 | :::tip
37 | Register your application to obtain Client ID and Client Secret at https://developer.wordpress.com/apps/ Select Type as Web and set Redirect URL to `http://example.com/api/auth/callback/wordpress` where example.com is your site domain.
38 | :::
39 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/yandex.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: yandex
3 | title: Yandex
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://tech.yandex.com/oauth/doc/dg/concepts/about-docpage/
9 |
10 | ## Configuration
11 |
12 | https://oauth.yandex.com/client/new
13 |
14 | ## Options
15 |
16 | The **Yandex Provider** comes with a set of default options:
17 |
18 | - [Yandex Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/yandex.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.Yandex({
29 | clientId: process.env.YANDEX_CLIENT_ID,
30 | clientSecret: process.env.YANDEX_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/zoho.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: zoho
3 | title: Zoho
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://www.zoho.com/accounts/protocol/oauth/web-server-applications.html
9 |
10 | ## Configuration
11 |
12 | https://api-console.zoho.com/
13 |
14 | ## Options
15 |
16 | The **Zoho Provider** comes with a set of default options:
17 |
18 | - [Zoho Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/zoho.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.Zoho({
29 | clientId: process.env.ZOHO_CLIENT_ID,
30 | clientSecret: process.env.ZOHO_CLIENT_SECRET
31 | })
32 | ]
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/providers/zoom.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: zoom
3 | title: Zoom
4 | ---
5 |
6 | ## Documentation
7 |
8 | https://marketplace.zoom.us/docs/guides/auth/oauth
9 |
10 | ## Configuration
11 |
12 | https://marketplace.zoom.us
13 |
14 | ## Options
15 |
16 | The **Zoom Provider** comes with a set of default options:
17 |
18 | - [Zoom Provider options](https://github.com/nextauthjs/next-auth/blob/ead715219a5d7a6e882a6ba27fa56b03954d062d/src/providers/zoom.js)
19 |
20 | You can override any of the options to suit your own use case.
21 |
22 | ## Example
23 |
24 | ```js
25 | import Providers from `next-auth/providers`
26 | ...
27 | providers: [
28 | Providers.Zoom({
29 | clientId: process.env.ZOOM_CLIENT_ID,
30 | clientSecret: process.env.ZOOM_CLIENT_SECRET
31 | })
32 | }
33 | ...
34 | ```
35 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/tutorials/typeorm-custom-models.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: typeorm-custom-models
3 | title: Custom models with TypeORM
4 | ---
5 |
6 | NextAuth.js provides a set of [models and schemas](/adapters/models) for the built-in TypeORM adapter that you can easily extend.
7 |
8 | You can use these models with MySQL, MariaDB, Postgres, MongoDB and SQLite.
9 |
10 | ## Creating custom models
11 |
12 | ```js title="models/User.js"
13 | import Adapters from "next-auth/adapters"
14 |
15 | // Extend the built-in models using class inheritance
16 | export default class User extends Adapters.TypeORM.Models.User.model {
17 | // You can extend the options in a model but you should not remove the base
18 | // properties or change the order of the built-in options on the constructor
19 | constructor(name, email, image, emailVerified) {
20 | super(name, email, image, emailVerified)
21 | }
22 | }
23 |
24 | export const UserSchema = {
25 | name: "User",
26 | target: User,
27 | columns: {
28 | ...Adapters.TypeORM.Models.User.schema.columns,
29 | // Adds a phoneNumber to the User schema
30 | phoneNumber: {
31 | type: "varchar",
32 | nullable: true,
33 | },
34 | },
35 | }
36 | ```
37 |
38 | ```js title="models/index.js"
39 | // To make importing them easier, you can export all models from single file
40 | import User, { UserSchema } from "./User"
41 |
42 | export default {
43 | User: {
44 | model: User,
45 | schema: UserSchema,
46 | },
47 | }
48 | ```
49 |
50 | :::note
51 | [View source for built-in TypeORM models and schemas](https://github.com/nextauthjs/adapters/tree/canary/packages/typeorm-legacy/src/models)
52 | :::
53 |
54 | ## Using custom models
55 |
56 | You can use custom models by specifying the TypeORM adapter explicitly and passing them as an option.
57 |
58 | ```js title="pages/api/auth/[...nextauth].js"
59 | import NextAuth from "next-auth"
60 | import Providers from "next-auth/providers"
61 | import Adapters from "next-auth/adapters"
62 |
63 | import Models from "../../../models"
64 |
65 | export default NextAuth({
66 | providers: [
67 | // Your providers
68 | ],
69 |
70 | adapter: Adapters.TypeORM.Adapter(
71 | // The first argument should be a database connection string or TypeORM config object
72 | "mysql://username:password@127.0.0.1:3306/database_name",
73 | // The second argument can be used to pass custom models and schemas
74 | {
75 | models: {
76 | User: Models.User,
77 | },
78 | }
79 | ),
80 | })
81 | ```
82 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/tutorials/usage-with-class-components.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: usage-with-class-components
3 | title: Usage with class components
4 | ---
5 |
6 | If you want to use the `useSession()` hook in your class components you can do so with the help of a higher order component or with a render prop.
7 |
8 | ## Higher Order Component
9 |
10 | ```js
11 | import { useSession } from "next-auth/client"
12 |
13 | const withSession = (Component) => (props) => {
14 | const [session, loading] = useSession()
15 |
16 | // if the component has a render property, we are good
17 | if (Component.prototype.render) {
18 | return
19 | }
20 |
21 | // if the passed component is a function component, there is no need for this wrapper
22 | throw new Error(
23 | [
24 | "You passed a function component, `withSession` is not needed.",
25 | "You can `useSession` directly in your component.",
26 | ].join("\n")
27 | )
28 | }
29 |
30 | // Usage
31 | class ClassComponent extends React.Component {
32 | render() {
33 | const { session, loading } = this.props
34 | return null
35 | }
36 | }
37 |
38 | const ClassComponentWithSession = withSession(ClassComponent)
39 | ```
40 |
41 | ## Render Prop
42 |
43 | ```js
44 | import { useSession } from "next-auth/client"
45 |
46 | const UseSession = ({ children }) => {
47 | const [session, loading] = useSession()
48 | return children({ session, loading })
49 | }
50 |
51 | // Usage
52 | class ClassComponent extends React.Component {
53 | render() {
54 | return (
55 |
56 | {({ session, loading }) => (
57 |
{JSON.stringify(session, null, 2)}
58 | )}
59 |
60 | )
61 | }
62 | }
63 | ```
64 |
--------------------------------------------------------------------------------
/versioned_docs/version-v3/warnings.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: warnings
3 | title: Warnings
4 | ---
5 |
6 | This is a list of warning output from NextAuth.js.
7 |
8 | All warnings indicate things which you should take a look at, but do not inhibit normal operation.
9 |
10 | ---
11 |
12 | ## Client
13 |
14 | #### NEXTAUTH_URL
15 |
16 | Environment variable `NEXTAUTH_URL` missing. Please set it in your `.env` file.
17 |
18 | ---
19 |
20 | ## Server
21 |
22 | These warnings are displayed on the terminal.
23 |
24 | #### JWT_AUTO_GENERATED_SIGNING_KEY
25 |
26 | To remedy this warning, you can either:
27 |
28 | **Option 1**: Pass a pre-regenerated Private Key (and, optionally a Public Key) in the jwt options.
29 |
30 | ```js title="/pages/api/auth/[...nextauth].js"
31 | jwt: {
32 | signingKey: process.env.JWT_SIGNING_PRIVATE_KEY,
33 |
34 | // You can also specify a public key for verification if using public/private key (but private only is fine)
35 | // verificationKey: process.env.JWT_SIGNING_PUBLIC_KEY,
36 |
37 | // If you want to use some key format other than HS512 you can specify custom options to use
38 | // when verifying (note: verificationOptions should include a value for maxTokenAge as well).
39 | // verificationOptions = {
40 | // maxTokenAge: `${maxAge}s`, // e.g. `${30 * 24 * 60 * 60}s` = 30 days
41 | // algorithms: ['HS512']
42 | // },
43 | }
44 | ```
45 |
46 | You can use [node-jose-tools](https://www.npmjs.com/package/node-jose-tools) to generate keys on the command line and set them as environment variables, i.e. `jose newkey -s 256 -t oct -a HS512`.
47 |
48 | **Option 2**: Specify custom encode/decode functions on the jwt object. This gives you complete control over signing / verification / etc.
49 |
50 | #### JWT_AUTO_GENERATED_ENCRYPTION_KEY
51 |
52 | #### SIGNIN_CALLBACK_REJECT_REDIRECT
53 |
54 | You returned something in the `signIn` callback, that is being deprecated.
55 |
56 | You probably had something similar in the callback:
57 |
58 | ```js
59 | return Promise.reject("/some/url")
60 | ```
61 |
62 | or
63 |
64 | ```js
65 | throw "/some/url"
66 | ```
67 |
68 | To remedy this, simply return the url instead:
69 |
70 | ```js
71 | return "/some/url"
72 | ```
73 |
74 | #### STATE_OPTION_DEPRECATION
75 |
76 | You provided `state: true` or `state: false` as a provider option. This is being deprecated in a later release in favour of `protection: "state"` and `protection: "none"` respectively. To remedy this warning:
77 |
78 | - If you use `state: true`, just simply remove it. The default is `protection: "state"` already..
79 | - If you use `state: false`, set `protection: "none"`.
80 |
--------------------------------------------------------------------------------
/versions.json:
--------------------------------------------------------------------------------
1 | ["v3"]
2 |
--------------------------------------------------------------------------------