giorgosera
09/01/2022, 4:33 PMjavascript
const providers = connections.map(({ id, authUrl, tokenUrl, clientId, clientSecret, scopes }) => {
return {
id,
get: (redirectURI: undefined | string, authCodeFromRequest: undefined | string) => {
return {
accessTokenAPI: {
url: tokenUrl,
params: {
client_id: clientId,
client_secret: clientSecret,
grant_type: "authorization_code",
redirect_uri: process.env.AUTH_SUCCESS_REDIRECT_URI,
code: authCodeFromRequest || '',
}
},
authorisationRedirect: {
url: authUrl,
params: {
client_id: clientId,
scope: scopes,
response_type: "code",
redirect_uri: process.env.AUTH_SUCCESS_REDIRECT_URI,
}
},
getClientId: () => clientId,
getProfileInfo: async (accessTokenAPIResponse: any) => {
console.log(accessTokenAPIResponse);
return {
id: "...",
};
}
}
}
}
});
I can successfully login with a provider and I can see I can get redirected to the process.env.AUTH_SUCCESS_REDIRECT_URI
. But the code inside getProfileInfo
is never called.
Also, I have followed the guide (https://supertokens.com/docs/thirdparty/common-customizations/getting-provider-access-token) to get the provider access token but that doesn't get called either.
What am I doing wrong?giorgosera
09/01/2022, 4:35 PMrp_st
09/01/2022, 5:45 PMrp_st
09/01/2022, 5:45 PMrp_st
09/01/2022, 5:46 PMgiorgosera
09/01/2022, 7:07 PMgiorgosera
09/01/2022, 7:08 PMThirdParty.redirectToThirdPartyLogin({ thirdPartyId: 'slack' })
giorgosera
09/01/2022, 7:09 PMprocess.env.AUTH_SUCCESS_REDIRECT_URI
that I use as a redirect URI is in fact a custom API route /auth/success
. The route handler then redirects to the frontend website.giorgosera
09/01/2022, 7:09 PMgiorgosera
09/01/2022, 9:17 PMrp_st
09/01/2022, 10:51 PMrp_st
09/01/2022, 10:52 PMgiorgosera
09/02/2022, 8:30 AMrp_st
09/02/2022, 8:31 AMgiorgosera
09/02/2022, 8:32 AMgiorgosera
09/02/2022, 8:33 AMgiorgosera
09/02/2022, 8:35 AMstate
value returned by the provider in the callback if I am handling it in my own route? Do I need to pass any arguments somewhere?rp_st
09/02/2022, 9:03 AMrp_st
09/02/2022, 9:04 AMgiorgosera
09/02/2022, 9:09 AMgiorgosera
09/02/2022, 9:09 AMrp_st
09/02/2022, 9:10 AMgiorgosera
09/02/2022, 9:11 AMThirdParty.redirectToThirdPartyLogin({ thirdPartyId: 'slack' })
2. The user goes through the auth process with the provider
3. The provider redirects the user back to whatever redirect uri I set
4. Now at this stage I need to call https://supertokens.com/docs/auth-react/modules/recipe_thirdparty.html#signInAndUp-1giorgosera
09/02/2022, 9:11 AMgiorgosera
09/02/2022, 9:12 AMgiorgosera
09/02/2022, 9:12 AMsignInAndUp
? Is there any callback returned by redirectToThirdPartyLogin
?rp_st
09/02/2022, 9:14 AMgiorgosera
09/02/2022, 9:19 AMgiorgosera
09/02/2022, 9:19 AMgiorgosera
09/02/2022, 9:20 AM/auth/callback/<providerId>
or /login/callback/<providerId>
?
According to the docs and my own config should be the /login/callback/<providerId>
one right?rp_st
09/02/2022, 9:21 AMgiorgosera
09/02/2022, 9:21 AMgiorgosera
09/02/2022, 9:21 AMrp_st
09/02/2022, 9:21 AMrp_st
09/02/2022, 9:22 AMgiorgosera
09/02/2022, 9:23 AMrp_st
09/02/2022, 9:23 AMrp_st
09/02/2022, 9:23 AMrp_st
09/02/2022, 9:23 AMrp_st
09/02/2022, 9:23 AMgiorgosera
09/02/2022, 9:25 AM/login/callback/<providerId>
as expected by supertokensgiorgosera
09/02/2022, 9:26 AMSignInAndUpCallback
giorgosera
09/02/2022, 9:26 AMrp_st
09/02/2022, 9:30 AMSignInAndUpCallback />
component which will take care of things for you and show our default spinner UI
Method 3) Build your own route + your own UI and call the ThirdParty.signInAndUp()
function yourself in a useEffect
Since you are building your own UI, I would recommend doing Method 3giorgosera
09/02/2022, 9:31 AMgiorgosera
09/02/2022, 9:32 AMgiorgosera
09/02/2022, 9:37 AMgiorgosera
09/02/2022, 9:38 AMgiorgosera
09/02/2022, 9:38 AMrp_st
09/02/2022, 9:39 AMrp_st
09/02/2022, 9:39 AMgiorgosera
09/02/2022, 9:40 AMgiorgosera
09/02/2022, 9:40 AMrp_st
09/02/2022, 9:46 AMgiorgosera
09/02/2022, 10:30 AMlogin?rid=thirdparty&error=no_email_present
Looking at the error param I thought to check the getProfileInfo
for the provider. My implementation just returns the id back and I can see that the return type: https://github.com/supertokens/supertokens-node/blob/5a00a138/lib/ts/recipe/thirdparty/types.ts#L32 doesn't require an email to be returned, just the id.
What might be the issue here?rp_st
09/02/2022, 10:32 AMrp_st
09/02/2022, 10:32 AMgiorgosera
09/02/2022, 10:32 AMgiorgosera
09/02/2022, 10:32 AMgiorgosera
09/02/2022, 10:33 AMrp_st
09/02/2022, 10:33 AMrp_st
09/02/2022, 10:34 AMrp_st
09/02/2022, 10:34 AMgiorgosera
09/02/2022, 10:35 AMgiorgosera
09/02/2022, 10:36 AMrp_st
09/02/2022, 10:36 AMgiorgosera
09/02/2022, 10:36 AMsignInUpPOST
giorgosera
09/02/2022, 10:37 AMrp_st
09/02/2022, 10:37 AMrp_st
09/02/2022, 10:38 AMgiorgosera
09/02/2022, 10:38 AMgiorgosera
09/02/2022, 10:38 AMgiorgosera
09/02/2022, 10:39 AMrp_st
09/02/2022, 10:39 AMgiorgosera
09/02/2022, 10:40 AMrp_st
09/02/2022, 10:40 AM