Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reddit Provider and Documentation #1094

Merged
merged 10 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/providers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -57,6 +58,7 @@ export default {
Mixer,
Netlify,
Okta,
Reddit,
Slack,
Spotify,
Strava,
Expand Down
13 changes: 6 additions & 7 deletions src/providers/reddit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Logging in works but trying to retrieve the profile results in 401 unauthorized
export default (options) => {
return {
id: 'reddit',
Expand All @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions www/docs/configuration/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion www/docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
64 changes: 64 additions & 0 deletions www/docs/providers/reddit.md
Original file line number Diff line number Diff line change
@@ -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,
}
}
}
]
```
:::
1 change: 1 addition & 0 deletions www/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module.exports = {
'providers/mixer',
'providers/netlify',
'providers/okta',
'providers/reddit',
'providers/slack',
'providers/spotify',
'providers/strava',
Expand Down