Google OAuth

Learn how to configure Google OAuth.

Set Up Google OAuth

Create project

Go to Google Cloud Console and login.

In the top left corner, click on the project dropdown and select New Project.

Choose a project name and click Create.

Once created, select the project.

Hover over the APIs & Services tab and click OAuth consent screen.

Click Get started and fill in the application name, user support email, and developer contact information.

Optionally, if you have a domain, fill in the application home page, privacy policy, and terms of service URLs.

For Audience, choose External and click Create.

Create OAuth client ID

Hover over the APIs & Services tab and click Credentials.

Next, click Create Credentials and select OAuth client ID.

Choose Web application as the type.

Add authorized redirect URIs:

http://localhost:3000/api/auth/callback/google

For production:

https://your-domain.com/api/auth/callback/google

Click Create.

Update the environment variables

Copy the Client ID and paste it beside GOOGLE_CLIENT_ID in the .env file.

Copy the Client Secret and paste it beside GOOGLE_CLIENT_SECRET in the .env file.

.env
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret

Test the integration

Restart the server and go to http://localhost:3000/signin.

Click Sign in with Google.

It may take a few minutes for Google OAuth to work after creating the application.

Push to Production

Go to OAuth consent screen, select Branding and click Verify branding.

Once verified, click Publish branding.

Now, anyone can sign in with their Google account.