Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How can I test login with Google via OAuth on my dev system?

To create a Google OAuth set of IDs, I have to provide a verified domain. But my dev system is localhost. Is there a way to test the login with Google on it?

thanks - dave

Solved Solved
0 3 462
1 ACCEPTED SOLUTION

Hi @DavidThielen,

Welcome to Google Cloud Community!

You're correct; Google OAuth does indeed require a verified domain, which complicates development on localhost.

Here are potential ways that might help with your use case:

  • Using http:// localhost with a Specific Port: To use http:// localhost with a specific port for your OAuth 2.0 Client IDs, create them in your Google Cloud Console project. Specify your redirect URIs with http:// localhost followed by a port number (e.g., http:// localhost:3000). Remember to use http:// instead of https:// as Google doesn't permit https for your local development with these URIs.
  • Using a Custom Hostname Mapped to 127.0.0.1: To set up a custom hostname mapped to 127.0.0.1, modify your hosts file to include 127.0.0.1 my-dev-domain.local, use this as your redirect URI in the Google Cloud Console, and configure your application accordingly. This maps your my-dev-domain.local to 127.0.0.1, allowing your application to handle the callback. It requires you to modify your hosts file on each machine
  • Environment Variables: You may store your Google OAuth client IDs, secrets, and redirect URIs in your environment variables. This practice enables seamless switching between development and production settings.

You may refer to the documentation below, which offers pertinent information on Setting up OAuth 2.0, and Create a VM instance with a custom hostname.

Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.

View solution in original post

3 REPLIES 3
Top Labels in this Space
Top Solution Authors