Michael Brant
06/23/2022, 5:46 PMrp_st
06/23/2022, 5:46 PMrp_st
06/23/2022, 5:52 PMThirdParty.init({
signInAndUpFeature: {
disableDefaultUI: true,
providers: [...]
}
})
The above will disable the UI shown on /auth route.
Then make your own component that's shown on /auth route, and do something like:
function AuthComponent(props: any) {
useEffect(() => {
Session.doesSessionExist().then(sessionExists => {
if (sessionExists) {
// TODO: redirect to dashboard or wherever
} else {
ThirdParty.redirectToThirdPartyLogin({
thirdPartyId: "google"
});
}
})
}, []);
return null;
}
rp_st
06/23/2022, 5:52 PMMichael Brant
06/23/2022, 6:07 PMrp_st
06/23/2022, 6:40 PMrp_st
06/23/2022, 6:41 PMrp_st
06/23/2022, 6:46 PMThirdParty.redirectToThirdPartyLogin
, you can fetch the redirect URL from the backend and manually redirect the user to that URL.
Here is an explanation of which API to query on the backend to get the URL: https://supertokens.com/blog/adding-social-login-to-your-website-with-supertokensMichael Brant
06/23/2022, 7:50 PMrp_st
06/24/2022, 3:55 AMnkshah2
06/24/2022, 3:57 AMrp_st
06/24/2022, 3:59 AMnkshah2
06/24/2022, 4:33 AMtry.supertokens.io
as the apiDomain which is incorrect, the way SuperTokens works is that you have a frontend, backend (both using SuperTokens SDKs) and a SuperTokens core (You can see the full architecture here: https://supertokens.com/docs/thirdparty/architecture). try.supertokens.io
is a SuperTokens core that we host for demo purposes.
Once you have the right architecture set up, your code example should work fine. Another thing to keep in mind is that codesandbox can change the URL for your frontend app (For example for me it would use https://ebse6e.csb.app/
after a couple refreshes) which means you would need to update the values you pass when you call SuperTokens.initSuperTokens is an open source authentication solution offering features like: Different types of login: Email / password, Passwordless (OTP or Magic link based).
Powered by