Adds OAuth2 sign-in to a Payload site by configuring passport-oauth2 and mounting authorize and callback routes. It also adds a sign-in button to the login page. The plugin is registered once per provider with unique paths, and a userinfo function maps the provider's response to a user. Version 2 targets Payload v2 and version 1 targets Payload v1.
Add oAuth sign in to your Payload CMS site
Installation
npm i payload-plugin-oauth113
Stars
15
Forks
12
Open Issues
6 months ago
Last Updated
70
Weekly Downloads
v2.2.1
npm Version
23.7 KB
Unpacked Size
5
Dependencies
113+1 since Sep 7
| Date | Stars |
|---|---|
| Dec 6, 2026 | 113 |
| Dec 5, 2026 | 113 |
| Dec 4, 2026 | 113 |
| Dec 3, 2026 | 113 |
| Dec 2, 2026 | 113 |
| Dec 1, 2026 | 113 |
| Nov 30, 2026 | 113 |
| Nov 29, 2026 | 112 |
| Nov 28, 2026 | 112 |
| Nov 27, 2026 | 112 |
| Nov 26, 2026 | 112 |
| Nov 25, 2026 | 112 |
| Nov 24, 2026 | 112 |
| Nov 23, 2026 | 112 |
| Nov 22, 2026 | 112 |
| Nov 21, 2026 | 112 |
| Nov 20, 2026 | 112 |
| Nov 19, 2026 | 112 |
| Nov 18, 2026 | 112 |
| Nov 17, 2026 | 112 |
| Nov 16, 2026 | 112 |
| Nov 15, 2026 | 112 |
| Nov 14, 2026 | 112 |
| Nov 13, 2026 | 112 |
| Nov 12, 2026 | 112 |
| Nov 11, 2026 | 112 |
| Nov 10, 2026 | 112 |
| Nov 9, 2026 | 112 |
| Nov 8, 2026 | 112 |
| Nov 7, 2026 | 112 |
| Nov 6, 2026 | 112 |
| Nov 5, 2026 | 112 |
| Nov 4, 2026 | 112 |
| Nov 3, 2026 | 112 |
| Nov 2, 2026 | 112 |
| Nov 1, 2026 | 112 |
| Oct 31, 2026 | 112 |
| Oct 30, 2026 | 112 |
| Oct 29, 2026 | 112 |
| Oct 28, 2026 | 112 |
| Oct 27, 2026 | 112 |
| Oct 26, 2026 | 112 |
| Oct 25, 2026 | 112 |
| Oct 24, 2026 | 112 |
| Oct 23, 2026 | 112 |
| Oct 22, 2026 | 112 |
| Oct 21, 2026 | 112 |
| Oct 20, 2026 | 112 |
| Oct 19, 2026 | 112 |
| Oct 18, 2026 | 112 |
| Oct 17, 2026 | 112 |
| Oct 16, 2026 | 112 |
| Oct 15, 2026 | 112 |
| Oct 14, 2026 | 112 |
| Oct 13, 2026 | 112 |
| Oct 12, 2026 | 112 |
| Oct 11, 2026 | 112 |
| Oct 10, 2026 | 112 |
| Oct 9, 2026 | 112 |
| Oct 8, 2026 | 112 |
| Oct 7, 2026 | 112 |
| Oct 6, 2026 | 112 |
| Oct 5, 2026 | 112 |
| Oct 4, 2026 | 112 |
| Oct 3, 2026 | 112 |
| Oct 2, 2026 | 112 |
| Oct 1, 2026 | 112 |
| Sep 30, 2026 | 112 |
| Sep 29, 2026 | 112 |
| Sep 28, 2026 | 112 |
| Sep 27, 2026 | 112 |
| Sep 26, 2026 | 112 |
| Sep 25, 2026 | 112 |
| Sep 24, 2026 | 112 |
| Sep 23, 2026 | 112 |
| Sep 22, 2026 | 112 |
| Sep 21, 2026 | 112 |
| Sep 20, 2026 | 112 |
| Sep 19, 2026 | 112 |
| Sep 18, 2026 | 112 |
| Sep 17, 2026 | 112 |
| Sep 16, 2026 | 112 |
| Sep 15, 2026 | 112 |
| Sep 14, 2026 | 112 |
| Sep 13, 2026 | 112 |
| Sep 12, 2026 | 112 |
| Sep 11, 2026 | 112 |
| Sep 10, 2026 | 112 |
| Sep 9, 2026 | 112 |
| Sep 8, 2026 | 112 |
| Sep 7, 2026 | 112 |
70−7 since Sep 7
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 70 |
| Dec 5, 2026 | 39 |
| Dec 4, 2026 | 37 |
| Dec 3, 2026 | 42 |
| Dec 2, 2026 | 47 |
| Dec 1, 2026 | 67 |
| Nov 30, 2026 | 82 |
| Nov 29, 2026 | 86 |
| Nov 28, 2026 | 91 |
| Nov 27, 2026 | 90 |
| Nov 26, 2026 | 90 |
| Nov 25, 2026 | 82 |
| Nov 24, 2026 | 67 |
| Nov 23, 2026 | 54 |
| Nov 22, 2026 | 47 |
| Nov 21, 2026 | 41 |
| Nov 20, 2026 | 43 |
| Nov 19, 2026 | 36 |
| Nov 18, 2026 | 32 |
| Nov 17, 2026 | 26 |
| Nov 16, 2026 | 21 |
| Nov 15, 2026 | 29 |
| Nov 14, 2026 | 33 |
| Nov 13, 2026 | 32 |
| Nov 12, 2026 | 38 |
| Nov 11, 2026 | 39 |
| Nov 10, 2026 | 45 |
| Nov 9, 2026 | 46 |
| Nov 8, 2026 | 36 |
| Nov 7, 2026 | 42 |
| Nov 6, 2026 | 35 |
| Nov 5, 2026 | 29 |
| Nov 4, 2026 | 28 |
| Nov 3, 2026 | 28 |
| Nov 2, 2026 | 35 |
| Nov 1, 2026 | 36 |
| Oct 31, 2026 | 37 |
| Oct 30, 2026 | 56 |
| Oct 29, 2026 | 51 |
| Oct 28, 2026 | 48 |
| Oct 27, 2026 | 54 |
| Oct 26, 2026 | 53 |
| Oct 25, 2026 | 60 |
| Oct 24, 2026 | 66 |
| Oct 23, 2026 | 47 |
| Oct 22, 2026 | 66 |
| Oct 21, 2026 | 82 |
| Oct 20, 2026 | 81 |
| Oct 19, 2026 | 78 |
| Oct 18, 2026 | 92 |
| Oct 17, 2026 | 86 |
| Oct 16, 2026 | 96 |
| Oct 15, 2026 | 86 |
| Oct 14, 2026 | 105 |
| Oct 13, 2026 | 103 |
| Oct 12, 2026 | 102 |
| Oct 11, 2026 | 83 |
| Oct 10, 2026 | 78 |
| Oct 9, 2026 | 74 |
| Oct 8, 2026 | 75 |
| Oct 7, 2026 | 48 |
| Oct 6, 2026 | 42 |
| Oct 5, 2026 | 41 |
| Oct 4, 2026 | 51 |
| Oct 3, 2026 | 54 |
| Oct 2, 2026 | 57 |
| Oct 1, 2026 | 54 |
| Sep 30, 2026 | 49 |
| Sep 29, 2026 | 66 |
| Sep 28, 2026 | 68 |
| Sep 27, 2026 | 59 |
| Sep 26, 2026 | 69 |
| Sep 25, 2026 | 69 |
| Sep 24, 2026 | 72 |
| Sep 23, 2026 | 80 |
| Sep 22, 2026 | 77 |
| Sep 21, 2026 | 76 |
| Sep 20, 2026 | 77 |
| Sep 19, 2026 | 63 |
| Sep 18, 2026 | 54 |
| Sep 17, 2026 | 58 |
| Sep 16, 2026 | 56 |
| Sep 15, 2026 | 39 |
| Sep 14, 2026 | 38 |
| Sep 13, 2026 | 40 |
| Sep 12, 2026 | 37 |
| Sep 11, 2026 | 51 |
| Sep 10, 2026 | 45 |
| Sep 9, 2026 | 55 |
| Sep 8, 2026 | 59 |
| Sep 7, 2026 | 77 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/562098618-root)<a href="https://payloaddirectory.dev/plugins/562098618-root"><img src="https://payloaddirectory.dev/badge/562098618-root.svg" alt="Payload Directory"></a>README
Payload v2
npm install payload-plugin-oauth@^2
# or
yarn add payload-plugin-oauth@^2
Payload v1
npm install payload-plugin-oauth@^1
# or
yarn add payload-plugin-oauth@^1
// payload.config.ts
import path from 'path'
import { webpackBundler } from '@payloadcms/bundler-webpack'
import { mongooseAdapter } from '@payloadcms/db-mongodb'
import { slateEditor } from '@payloadcms/richtext-slate'
import axios from 'axios'
import { oAuthPlugin } from 'payload-plugin-oauth'
import { buildConfig } from 'payload/config'
import Users from './collections/Users'
export default buildConfig({
admin: {
user: Users.slug,
bundler: webpackBundler(),
},
editor: slateEditor({}),
collections: [Users],
typescript: {
outputFile: path.resolve(__dirname, 'payload-types.ts'),
},
graphQL: {
schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
},
plugins: [
payloadCloud(),
oAuthPlugin({
buttonLabel: 'Sign in with oAuth',
databaseUri: process.env.DATABASE_URI,
clientID: process.env.OAUTH_CLIENT_ID,
clientSecret: process.env.OAUTH_CLIENT_SECRET,
authorizationURL: process.env.OAUTH_AUTH_ENDPOINT,
tokenURL: process.env.OAUTH_TOKEN_ENDPOINT,
authorizePath: '/oauth/authorize1',
callbackURL: process.env.ORIGIN + '/oauth/callback1',
async userinfo(accessToken) {
const { data: user } = await axios.get(
process.env.OAUTH_USERINFO_ENDPOINT,
{ headers: { Authorization: `Bearer ${accessToken}` } }
)
return {
sub: user.ID,
username: user.preferred_username,
}
},
}),
// Another oAuth provider
oAuthPlugin({
buttonLabel: 'Sign in with Alternative',
// These paths must be unique per provider
authorizePath: '/oauth/authorize2',
callbackURL: process.env.ORIGIN + '/oauth/callback2',
...rest,
}),
],
db: mongooseAdapter({
url: process.env.DATABASE_URI,
}),
})
Please see CHANGELOG for more information what has changed recently.
Contributions and feedback are very welcome.
To get it running:
npm installnpm run buildnpm run fixnpm version minorThe MIT License (MIT). Please see License File for more information.
Topics
payload authjs
Sign in to Payload CMS through Auth.js 5 providers and use the Auth.js session as the Payload user
903.1k/wk206v3
payload zitadel plugin
Log in to the Mzinga admin through Zitadel or another OIDC provider using authorization code with PKCE
72608/wk11v?
payload simple social login
Google and Microsoft social login for the Payload admin panel and auth collections
7119/wk3v3
payload auth
Replace Payload's built-in auth with Better Auth for a shared admin and frontend session
7021.0k/wk349v3
payload oauth2
Generic OAuth2 sign-in for Payload CMS with support for providers such as Google, Zitadel and Apple
6913.0k/wk200v3
oidc
OpenID Connect single sign-on for Payload using Authorization Code Flow with PKCE and native Payload sessions
65745/wk0v3