Skip to main content

Getting provider's access token

You can get the Third Party Provider's access token to query their APIs with the following method:

import SuperTokens from "supertokens-node";import ThirdPartyEmailPassword from "supertokens-node/recipe/thirdpartyemailpassword";import Session from "supertokens-node/recipe/session";
SuperTokens.init({    appInfo: {        apiDomain: "...",        appName: "...",        websiteDomain: "..."    },    supertokens: {        connectionURI: "...",    },    recipeList: [        ThirdPartyEmailPassword.init({            override: {                apis: (originalImplementation) => {                    return {                        ...originalImplementation,
                        // we override the thirdparty sign in / up API                        thirdPartySignInUpPOST: async function (input) {                            if (originalImplementation.thirdPartySignInUpPOST === undefined) {                                throw Error("Should never come here");                            }
                            let response = await originalImplementation.thirdPartySignInUpPOST(input);
                            // if sign in / up was successful...                            if (response.status === "OK") {                                // In this example we are using Google as our provider                                let accessToken = response.authCodeResponse.access_token
                                // TODO: ...                            }
                            return response;                        },                    }                }            },        }),        Session.init()    ]});
Which frontend SDK do you use?
supertokens-web-js / mobile
supertokens-auth-react