From d42dbc636e04a05d828089b7c4d60e34a1ead1fe Mon Sep 17 00:00:00 2001 From: Aymeric <34040599+afoyer@users.noreply.github.com> Date: Tue, 12 Jan 2021 08:38:04 -0700 Subject: [PATCH 1/9] Create reddit.md --- www/docs/providers/reddit.md | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 www/docs/providers/reddit.md diff --git a/www/docs/providers/reddit.md b/www/docs/providers/reddit.md new file mode 100644 index 0000000000..d4435732e4 --- /dev/null +++ b/www/docs/providers/reddit.md @@ -0,0 +1,38 @@ +--- +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 +You can expand the scope by passing the scope variable. The identity scope is required. +::: From 67a1e7e29533e2b8907e498423c32dfa9450387e Mon Sep 17 00:00:00 2001 From: Aymeric <34040599+afoyer@users.noreply.github.com> Date: Tue, 12 Jan 2021 08:45:55 -0700 Subject: [PATCH 2/9] uncommented profile callback --- src/providers/reddit.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/providers/reddit.js b/src/providers/reddit.js index 6f512bb1be..c44f1e46fb 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 } From 68b28eb8285e0fbcff76bd4b0a0154d4707b7c40 Mon Sep 17 00:00:00 2001 From: Aymeric <34040599+afoyer@users.noreply.github.com> Date: Tue, 12 Jan 2021 09:42:18 -0700 Subject: [PATCH 3/9] Update reddit.md --- www/docs/providers/reddit.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/www/docs/providers/reddit.md b/www/docs/providers/reddit.md index d4435732e4..5455d2596c 100644 --- a/www/docs/providers/reddit.md +++ b/www/docs/providers/reddit.md @@ -34,5 +34,31 @@ Only allows one callback URL per Client ID / Client Secret. ::: :::tip -You can expand the scope by passing the scope variable. The identity scope is required. +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, + } + } + } + ] +``` ::: From 78410267744ef220fbe094258ee7f9234c5d36b9 Mon Sep 17 00:00:00 2001 From: Aymeric <34040599+afoyer@users.noreply.github.com> Date: Tue, 12 Jan 2021 10:06:06 -0700 Subject: [PATCH 4/9] fix lint issues --- src/providers/reddit.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/providers/reddit.js b/src/providers/reddit.js index c44f1e46fb..8552030f07 100644 --- a/src/providers/reddit.js +++ b/src/providers/reddit.js @@ -12,11 +12,11 @@ export default (options) => { profileUrl: 'https://oauth.reddit.com/api/v1/me', profile: (profile) => { return { - id: profile.id, - name: profile.name, - image: null, - email: null, - }; + id: profile.id, + name: profile.name, + image: null, + email: null + } }, ...options } From 37649cc28f9e5bcebc005207c5f1849c3d5e3bee Mon Sep 17 00:00:00 2001 From: Aymeric <34040599+afoyer@users.noreply.github.com> Date: Tue, 12 Jan 2021 10:51:40 -0700 Subject: [PATCH 5/9] added reddit provider --- src/providers/index.js | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/providers/index.js b/src/providers/index.js index cfba2313fd..be773dfa28 100644 --- a/src/providers/index.js +++ b/src/providers/index.js @@ -1,67 +1,53 @@ import Apple from './apple' import Atlassian from './atlassian' import Auth0 from './auth0' -import AzureADB2C from './azure-ad-b2c' import Basecamp from './basecamp' import BattleNet from './battlenet' import Box from './box' -import Bungie from './bungie' -import Cognito from './cognito' import Credentials from './credentials' +import Cognito from './cognito' import Discord from './discord' import Email from './email' import Facebook from './facebook' -import Foursquare from './foursquare' import FusionAuth from './fusionauth' import GitHub from './github' import GitLab from './gitlab' import Google from './google' import IdentityServer4 from './identity-server4' -import LINE from './line' import LinkedIn from './linkedin' -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' import Twitch from './twitch' import Twitter from './twitter' -import VK from './vk' import Yandex from './yandex' export default { - Apple, Atlassian, Auth0, - AzureADB2C, + Apple, Basecamp, BattleNet, Box, - Bungie, - Cognito, Credentials, + Cognito, Discord, Email, Facebook, - Foursquare, FusionAuth, GitHub, GitLab, Google, IdentityServer4, - LINE, LinkedIn, - MailRu, Mixer, - Netlify, Okta, + Reddit, Slack, Spotify, - Strava, - Twitch, Twitter, - VK, + Twitch, Yandex } From 5483093c905a0ceb9e8710b79a9d72d31c02f128 Mon Sep 17 00:00:00 2001 From: Aymeric <34040599+afoyer@users.noreply.github.com> Date: Tue, 12 Jan 2021 10:55:18 -0700 Subject: [PATCH 6/9] added reddit provider --- www/sidebars.js | 1 + 1 file changed, 1 insertion(+) 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', From a6686fed7fa16125b29a7fc24db21e2cffbddaf3 Mon Sep 17 00:00:00 2001 From: Aymeric <34040599+afoyer@users.noreply.github.com> Date: Tue, 12 Jan 2021 11:00:19 -0700 Subject: [PATCH 7/9] Add Reddit Provider For some reason a bunch of providers got deleted in the last commit --- src/providers/index.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/providers/index.js b/src/providers/index.js index be773dfa28..b6115abcd1 100644 --- a/src/providers/index.js +++ b/src/providers/index.js @@ -1,53 +1,69 @@ import Apple from './apple' import Atlassian from './atlassian' import Auth0 from './auth0' +import AzureADB2C from './azure-ad-b2c' import Basecamp from './basecamp' import BattleNet from './battlenet' import Box from './box' -import Credentials from './credentials' +import Bungie from './bungie' import Cognito from './cognito' +import Credentials from './credentials' import Discord from './discord' import Email from './email' import Facebook from './facebook' +import Foursquare from './foursquare' import FusionAuth from './fusionauth' import GitHub from './github' import GitLab from './gitlab' import Google from './google' import IdentityServer4 from './identity-server4' +import LINE from './line' import LinkedIn from './linkedin' +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' import Twitch from './twitch' import Twitter from './twitter' +import VK from './vk' import Yandex from './yandex' export default { + Apple, Atlassian, Auth0, - Apple, + AzureADB2C, Basecamp, BattleNet, Box, - Credentials, + Bungie, Cognito, + Credentials, Discord, Email, Facebook, + Foursquare, FusionAuth, GitHub, GitLab, Google, IdentityServer4, + LINE, LinkedIn, + MailRu, Mixer, + Netlify, Okta, Reddit, Slack, Spotify, - Twitter, + Strava, Twitch, + Twitter, + VK, Yandex } From 5f68147414a12230ceaafb0ca9c104e155f67a1d Mon Sep 17 00:00:00 2001 From: Aymeric <34040599+afoyer@users.noreply.github.com> Date: Tue, 12 Jan 2021 11:02:20 -0700 Subject: [PATCH 8/9] Add Reddit Provider --- www/docs/configuration/providers.md | 1 + 1 file changed, 1 insertion(+) 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) From d562ad74c3469949ec5096947e3b5cea2c2c1f7c Mon Sep 17 00:00:00 2001 From: Aymeric <34040599+afoyer@users.noreply.github.com> Date: Tue, 12 Jan 2021 12:35:54 -0700 Subject: [PATCH 9/9] Add Reddit Provider --- www/docs/faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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).