How to add third parthy login with Supertokens (Google)
Step by step of how to integrate a google login in your application. Create the credentials in google and integrate everything in your application.
This guide will first cover the steps to get everything what you need from google to create the credentials that you need in your app and how to integrate it into your app using supertokens.
Get Google Credentials
(From the google official documentation page)
Navigate to the Google Auth Platform Clients page.
You will be prompted to create a project if you do not have one selected.
You will be prompted to register your application to use Google Auth if you are yet to do so. This is required before creating a client.
Click CREATE CLIENT
Select the appropriate application type for your application and enter any additional information required. Application types are described in more detail in the following sections.
Fill out the required information for the select client type and click the CREATE button to create the client.
Some things to take into account (using supertokens and translateprompt as example)
Authorised JavaScript origins:
["https://translateprompt.com", "http://localhost:5178"]
Authorised redirect URIs
["https://translateprompt.com/auth/callback/google", "http://localhost:5178/auth/callback/google"]
At the end you should be able to download a json with the credentials.
Setting up the third party login
Then in the backend of your app you can set the third party recipe.
# See supertokens docs for more examples
from supertokens_python import init, InputAppInfo
from supertokens_python.recipe import thirdparty
from supertokens_python.recipe.thirdparty import ProviderInput, ProviderConfig, ProviderClientConfig, SignInAndUpFeature
init(
app_info=InputAppInfo(api_domain="...", app_name="...", website_domain="..."),
framework='...',
recipe_list=[
thirdparty.init(
sign_in_and_up_feature=SignInAndUpFeature(
providers=[
ProviderInput(
config=ProviderConfig(
third_party_id="google",
clients=[
ProviderClientConfig(
client_id="1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com",
client_secret="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",
),
],
),
),
]
)
)
]
)
And in the Frontend
...
recipeList: [
Session.init(),
ThirdParty.init({
signInAndUpFeature: {
providers: [Google.init()]
}
})
]
# When using the prebuild ui
getSuperTokensRoutesForReactRouterDom(reactRouterDom, [
ThirdPartyPreBuiltUI
]);
After this you’re set to go!
Related Posts
How to add auth in your app using supertokens
Adding the option to the users to log in can be very simple or very tricky. In this post I'll show the steps to set up supertokens in a react app with fastapi (python) on the backenn. The supertokens instance will be selfhosted in coolify.
How to add pricing with Lemonsqueezy (python fastapi + React)
How to add pricing with lemonsqueezy, handle the webhooks, automatic redirects and changes to the DB
Simple Approach to write readable Logs
Writing Logs is a necessary part of every application, though it can also be tedious. This guide shows how to write minimal logs for an MVP to track what is going on in the app
Let's connect !!
Get in touch if you want updates, examples, and insights on how AI agents, Langchain and more are evolving and where they’re going next.