Files
archived-next-auth/docs/versioned_docs/version-beta/oauth-providers/reddit.md
Lluis Agusti cb56cd44ca refactor(docs): re-structure (#4498)
* docs: beta initial commit

* docs(oauth): finish initial tutorial

* docs(oauth-tutorial): finish guide

* docs(docusaurus): just log broken links

* docs: re-organising beta

* docs(beta): sort documents for sorting

* docs: more re-structure

* docs: more re-structure (2)

* fix: more WIP

* fix: more WIP

* chore: more updates

* chore: wip

* chore: wip

* fix lock file

* docs(getting-started): credentials

* chore: remove json-server file

* chore: cleanup

* remove mongodb from dev app

* chore: cleanup

* revert

* chore: cleanup

* chore: more cleanup changes

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-10-15 15:45:33 +01:00

1.7 KiB

id, title
id title
reddit Reddit

Documentation

https://www.reddit.com/dev/api/

Configuration

https://www.reddit.com/prefs/apps/

Options

The Reddit Provider comes with a set of default options:

You can override any of the options to suit your own use case.

Example

import RedditProvider from "next-auth/providers/reddit";
...
providers: [
  RedditProvider({
    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:

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,
      }
    },
  },
]

:::