4

I am deploying an app on Heroku that uses Google OAuth2. When I test the app, I go to the auth url (/auth/google) and I see the following error message (note that I replaced domain name with *** just for posting here:

  1. That’s an error.

Error: invalid_client

The OAuth client was not found.

Request Details response_type=code redirect_uri=https://****.com/auth/google/callback scope=profile email client_id=process.env.GOOGLE_CLIENT_ID That’s all we know.

I have looked at the following questions before posting and have been trying to debug for several hours:

Error: invalid_client with Google Apps API OAuth2

invalid_client in google oauth2

I have tried to do the following:

  1. Ensure there are no spaces before and after the values in Heroku

  2. The consent screen in Google Console has the name and email address completed

  3. I have renamed the app within Google Console

  4. I have deleted the key/value from Heroku and re-created

Despite all this, I am unable to fix this. Any ideas on what I maybe missing?

Captain Kirk
  • 916
  • 2
  • 7
  • 15

1 Answers1

6

The answer is in the question.

Google can't find any reference to your client, which is identified by the client_id in the URL. Instead of a valid client_id (which looks something like "40740878192.apps.googleusercontent.com") you have given a client_id of "process.env.GOOGLE_CLIENT_ID". It looks like a bug in your code that instead of using process.env.GOOGLE_CLIENT_ID as a variable, you have used it as a literal.

pinoyyid
  • 21,499
  • 14
  • 64
  • 115
  • 1
    Thanks @pinoyyid! Looks like that was indeed the issue - I had accidentally wrapped the variable in double quotes. Thanks for the assist! – Captain Kirk Jul 06 '18 at 15:00
  • 1
    I have exactly the same issue, I have followed the same steps as the poster of this issue, but my client id is actually a client id, not a string that says "CLIENT_ID". Any ideas? – alernerdev Jul 21 '18 at 15:00