This guide walks you through configuring Google OAuth for your app’s authentication. Your app’s users will be able to sign in with their Google accounts.
Prerequisites
- A published Replit app (you need a deployment URL like
your-app.replit.app)
- Access to the Google Cloud Console
Step 1: Publish your app
Before configuring custom OAuth credentials, you need a published deployment URL. You’ll need the URL when setting up your custom Google credentials.
- Publish your app from the Replit workspace
- Note your published URL (e.g.,
https://your-app.replit.app)
Step 2: Create a Google OAuth app
Navigate to the Google Cloud Console:
Create or select a project
- Select an existing project or create a new one from the project dropdown
- You’ll be redirected to your project’s Dashboard
- In the left sidebar, select the menu icon (≡) and select APIs & Services
- Select OAuth consent screen
- Configure your app’s consent screen with required information
- Save your changes
Create OAuth credentials
- From APIs & Services, select Credentials
- Select Create Credentials at the top, then select OAuth client ID
- Choose Web application as the application type
- Configure the following:
Authorized JavaScript origins:
Add your published app URL:
https://your-app.replit.app
If you have a custom domain, add that as well:
https://your-custom-domain.com
Authorized redirect URIs:
The redirect URI is your published domain followed by /__clerk/v1/oauth_callback. Add the following, replacing your-app.replit.app with your actual published domain:
https://your-app.replit.app/__clerk/v1/oauth_callback
If you have a custom domain:
https://your-custom-domain.com/__clerk/v1/oauth_callback
- Select Create
- Save your Client ID and Client Secret
Keep your Client Secret secure and never commit it to version control.
Step 3: Enter credentials in Replit
- In your Repl, navigate to the Auth pane
- Select the Configure tab
- Select Production environment
- Select the Edit button next to Google
- Toggle on Use custom credentials
- Paste your Client ID and Client Secret
- Select Save changes
- Toggle Google to Enabled
Step 4: Test your integration
- Open your published app’s login page
- Select Sign in with Google
- Complete the Google sign-in flow
- Verify successful authentication
Google sign-in does not work in embedded browsers or in-app webviews. Users must use a standard web browser.
Troubleshooting
Redirect URI mismatch
- Verify the redirect URI in Google Cloud Console is exactly
https://your-app.replit.app/__clerk/v1/oauth_callback
- Ensure there are no trailing slashes or typos
- Wait a few minutes for Google’s configuration to propagate
Invalid client
- Double-check Client ID and Client Secret are copied correctly
- Ensure there are no extra spaces
- Verify OAuth consent screen is configured
Not working on custom domain
- Add your custom domain to both Authorized JavaScript origins and Authorized redirect URIs
- Use the format
https://your-custom-domain.com/__clerk/v1/oauth_callback for the redirect URI
- Republish your app and clear browser cache