Google Authentication
You can use Google Authentication with Firebase or Supabase or the express-js app.
Google OAuth Setup
- Go to the Google Cloud Console.
- Go to the
APIs & Services
section. - Go to the
Credentials
section. - Click on
Create Credentials
and selectOAuth client ID
. - Select the
Application type
asWeb application
.- Remember you will need to register multple credentials for multiple platforms i.e. web, android, ios, etc.
- Follow the instructions to create the credentials.
- In the
Authorized redirect URIs
field, add the following URIs:http://localhost:3000/
(for Next)http://localhost:8081/
(for Expo)http://localhost:8080/
(for Express)
- In the
Authorized JavaScript origins
field, add the following origins:http://localhost:3000
(for Next)http://localhost:8081
(for Expo)http://localhost:8080
(for Express)
Firebase Setup
To use Google Authentication with Firebase as your provider, follow these steps:
- Go to your firebase console.
- Go to the
Authentication
section. - Select the
Sign-in method
tab. - Enable the
Google
authentication provider. - It should already have the client ID and client secret. If not, add them.
Supabase Setup
To use Google Authentication with Supabase as your provider, follow these steps:
- Go to the supabase dashboard of your project.
- Go to the
Authentication
section. - Click on the providers options.
- Enable the
Google
authentication. - Use whichever OAuth provider you want to use for authentication (Google, etc.).
- We recommend using Google OAuth.
- Add the
GOOGLE_CLIENT_ID
andGOOGLE_CLIENT_SECRET
andAuthorized Client IDs
for use withandroid/ios
provided by the OAuth provider to the options provided in the dashboard. - You will also get a callback URL here. Add it to the
Authorized redirect URIs
field in the Google Cloud Console of its respective project.
Express-app Setup
To use a custom REST API as your provider, follow these steps:
- Put the credentials i.e.
GOOGLE_CLIENT_ID
andGOOGLE_CLIENT_SECRET
in the env file atbackend/express-js/.env
. - Add respective callback URLs to the
Authorized redirect URIs
field in the Google Cloud Console of its respective project.http://localhost:8080/v1/auth/google/callback
(for Express)
After setting up the Google Authentication, you can use the signInWithGoogle
function to sign in with Google.
Google Authentication should now be setup for your app for all providers.
Native Apps
For any issues with native apps, you can refer to the RN Google Authentication guide.