diff --git a/src/providers/index.js b/src/providers/index.js index cfba2313fd..b6115abcd1 100644 --- a/src/providers/index.js +++ b/src/providers/index.js @@ -23,6 +23,7 @@ import MailRu from './mailru' import Mixer from './mixer' import Netlify from './netlify' import Okta from './okta' +import Reddit from './reddit' import Slack from './slack' import Spotify from './spotify' import Strava from './strava' @@ -57,6 +58,7 @@ export default { Mixer, Netlify, Okta, + Reddit, Slack, Spotify, Strava, diff --git a/src/providers/reddit.js b/src/providers/reddit.js index 6f512bb1be..8552030f07 100644 --- a/src/providers/reddit.js +++ b/src/providers/reddit.js @@ -1,4 +1,3 @@ -// Logging in works but trying to retrieve the profile results in 401 unauthorized export default (options) => { return { id: 'reddit', @@ -12,12 +11,12 @@ export default (options) => { 'https://www.reddit.com/api/v1/authorize?response_type=code', profileUrl: 'https://oauth.reddit.com/api/v1/me', profile: (profile) => { - // return { - // id: profile.id, - // name: profile.name, - // image: null, - // email: null, - // }; + return { + id: profile.id, + name: profile.name, + image: null, + email: null + } }, ...options } diff --git a/www/docs/configuration/providers.md b/www/docs/configuration/providers.md index a0568fada2..f3b43f21a2 100644 --- a/www/docs/configuration/providers.md +++ b/www/docs/configuration/providers.md @@ -34,6 +34,7 @@ NextAuth.js is designed to work with any OAuth service, it supports OAuth 1.0, 1 * [Mixer](/providers/mixer) * [Netlify](/providers/netlify) * [Okta](/providers/okta) +* [Reddit](/providers/reddit) * [Slack](/providers/slack) * [Spotify](/providers/spotify) * [Strava](/providers/strava) diff --git a/www/docs/faq.md b/www/docs/faq.md index 086d904e55..26b7cb0aa8 100644 --- a/www/docs/faq.md +++ b/www/docs/faq.md @@ -23,7 +23,7 @@ You can use also NextAuth.js with any database using a custom database adapter, ### What authentication services does NextAuth.js support? -NextAuth.js includes built-in support for signing in with Amazon Cognito, Apple, Atlassian, Auth0, Azure Active Directory B2C, Basecamp, Battle.net, Box, Bungie, Discord, Facebook, Foursquare, FusionAuth, GitHub, GitLab, Google, IdentityServer4, LINE, LinkedIn, Mail.ru, Mixer, Netlify, Okta, Slack, Spotify, Strava, Twitch, Twitter, VK and Yandex. (See also: [Providers](/configuration/providers)) +NextAuth.js includes built-in support for signing in with Amazon Cognito, Apple, Atlassian, Auth0, Azure Active Directory B2C, Basecamp, Battle.net, Box, Bungie, Discord, Facebook, Foursquare, FusionAuth, GitHub, GitLab, Google, IdentityServer4, LINE, LinkedIn, Mail.ru, Mixer, Netlify, Okta, Reddit, Slack, Spotify, Strava, Twitch, Twitter, VK and Yandex. (See also: [Providers](/configuration/providers)) NextAuth.js also supports email for passwordless sign in, which is useful for account recovery or for people who are not able to use an account with the configured OAuth services (e.g. due to service outage, account suspension or otherwise becoming locked out of an account). diff --git a/www/docs/providers/reddit.md b/www/docs/providers/reddit.md new file mode 100644 index 0000000000..5455d2596c --- /dev/null +++ b/www/docs/providers/reddit.md @@ -0,0 +1,64 @@ +--- +id: reddit +title: Reddit +--- + +## Documentation + +https://www.reddit.com/dev/api/ + +## Configuration + +https://www.reddit.com/prefs/apps/ + +## Example + +```js +import Providers from `next-auth/providers` +... +providers: [ + Providers.Reddit({ + clientId: process.env.REDDIT_CLIENT_ID, + clientSecret: process.env.REDDIT_CLIENT_SECRET + }) +} +... +``` + +:::warning +Reddit requires authorization every time you go through their page. +::: + +:::warning +Only allows one callback URL per Client ID / Client Secret. +::: + +:::tip +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: + +```js +providers: [ + { + id: "reddit", + name: "Reddit", + clientId: process.env.REDDIT_CLIENT_ID, + clientSecret: process.env.REDDIT_CLIENT_SECRET, + scope: "identity mysubreddits read", //Check Reddit API Documentation for more. The identity scope is required. + type: "oauth", + version: "2.0", + params: { grant_type: "authorization_code" }, + accessTokenUrl: " https://www.reddit.com/api/v1/access_token", + authorizationUrl: + "https://www.reddit.com/api/v1/authorize?response_type=code&duration=permanent", + profileUrl: "https://oauth.reddit.com/api/v1/me", + profile: (profile) => { + return { + id: profile.id, + name: profile.name, + email: null, + } + } + } + ] +``` +::: diff --git a/www/sidebars.js b/www/sidebars.js index 9a777d8c8a..f3204ff860 100644 --- a/www/sidebars.js +++ b/www/sidebars.js @@ -49,6 +49,7 @@ module.exports = { 'providers/mixer', 'providers/netlify', 'providers/okta', + 'providers/reddit', 'providers/slack', 'providers/spotify', 'providers/strava',