Skip to main content
Which frontend SDK do you use?
supertokens-web-js / mobile
supertokens-auth-react

Built in providers

SuperTokens currently supports the following providers, but you can also add your own custom provider:

  • Apple (thirdPartyId: "apple")
  • Discord (thirdPartyId: "discord")
  • Facebook (thirdPartyId: "facebook")
  • Github (thirdPartyId: "github")
  • Google (thirdPartyId: "google")
  • LinkedIn (thirdPartyId: "linkedin")

Step 1: Frontend setup#

Import and all the built in providers that you wish to show in the UI as shown below.

import SuperTokens from "supertokens-auth-react";import ThirdParty, {Google, Github, Facebook, Apple} from "supertokens-auth-react/recipe/thirdparty";SuperTokens.init({    appInfo: {        apiDomain: "...",        appName: "...",        websiteDomain: "..."    },    recipeList: [        ThirdParty.init({            signInAndUpFeature: {                providers: [                    Github.init(),                    Google.init(),                    Facebook.init(),                    Apple.init(),                ],                // ...            },            // ...        }),        // ...    ]});

Changing the button style #

On the frontend, you can provide a button component to the in built providers defining your own UI. The component you add will be clickable by default.

import SuperTokens from "supertokens-auth-react";import ThirdParty, {Google, Github, Facebook, Apple} from "supertokens-auth-react/recipe/thirdparty";SuperTokens.init({    appInfo: {        apiDomain: "...",        appName: "...",        websiteDomain: "..."    },    recipeList: [        ThirdParty.init({            signInAndUpFeature: {                providers: [                    Github.init({                        buttonComponent: (props: {name: string}) => <div></div>                    }),                    Google.init({                        buttonComponent: (props: {name: string}) => <div></div>                    }),                    Facebook.init({                        buttonComponent: (props: {name: string}) => <div></div>                    }),                    Apple.init({                        buttonComponent: (props: {name: string}) => <div></div>                    }),                ],                 // ...            },            // ...        }),        // ...    ]});

Step 2: Adding providers config to the backend#

You should add all the built in providers to the providers array during the init function call on the backend. At a minimum, you will require the client ID and secret (unless the provider supports PKCE flow), but you can also change our default behaviour for any of the in built providers.

import SuperTokens from "supertokens-node";import Session from "supertokens-node/recipe/session";import ThirdParty from "supertokens-node/recipe/thirdparty";let { Google, Github, Facebook, Apple } = ThirdParty
TODO
SuperTokens.init({    appInfo: {        apiDomain: "...",        appName: "...",        websiteDomain: "..."    },    supertokens: {        connectionURI: "...",    },    recipeList: [        ThirdParty.init({            signInAndUpFeature: {                providers: [                    Google({                        clientSecret: "TODO: GOOGLE_CLIENT_SECRET",                        clientId: "TODO: GOOGLE_CLIENT_ID"                    }),                    Github({                        clientSecret: "TODO: GITHUB_CLIENT_SECRET",                        clientId: "TODO: GITHUB_CLIENT_ID"                    }),                    Facebook({                        clientSecret: "TODO: FACEBOOK_CLIENT_SECRET",                        clientId: "TODO: FACEBOOK_CLIENT_ID"                    }),                    Apple({                        clientSecret: {                            teamId: "APPLE_TEAM_ID",                            privateKey: "APPLE_PRIVATE_KEY",                            keyId: "KEY_ID"                        },                        clientId: "APPLE_CLIENT_ID"                    })                ]            }        }), // initializes signin / sign up features         Session.init() // initializes session features    ]});
  • You can see all the configs available for each of our built in providers over here
  • Make sure that the above configurations for "CLIENT_SECRET" are stored in your environment variables and not directly in your source code files.

Setting OAuth Scopes#

If you would like to add additional OAuth Scopes when accessing your third party provider, you can do so by adding them to the config when initializing the backend SDK.

For example if you are using Google as your third party provider, you can add an additional scope as follows:

import SuperTokens from "supertokens-node";import ThirdParty from "supertokens-node/recipe/thirdparty";
TODO
SuperTokens.init({    supertokens: {        connectionURI: "...",    },    appInfo: {        apiDomain: "...",        appName: "...",        websiteDomain: "..."    },    recipeList: [        ThirdParty.init({            signInAndUpFeature: {                providers: [                    ThirdParty.Google({                        clientSecret: "TODO: GOOGLE_CLIENT_SECRET",                        clientId: "TODO: GOOGLE_CLIENT_ID",                        scope: [                            "additionalFeatureURL",                        ]                    })                ]            }        })    ]});
important

Your scopes should ensure that the provider returns the user's email.

See also#