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 ThirdParty from "supertokens-node/recipe/thirdparty";import Session from "supertokens-node/recipe/session";
SuperTokens.init({    appInfo: {        apiDomain: "...",        appName: "...",        websiteDomain: "..."    },    supertokens: {        connectionURI: "...",    },    recipeList: [        ThirdParty.init({            signInAndUpFeature: {                providers: [/* ... */]            },            override: {                apis: (originalImplementation) => {                    return {                        ...originalImplementation,
                        signInUpPOST: async function (input) {
                            if (originalImplementation.signInUpPOST === undefined) {                                throw Error("Should never come here");                            }
                            let response = await originalImplementation.signInUpPOST(input)
                            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