invalid_client in google oauth2
Asked Answered
F

26

100

I try to make a web page for youtube video upload, therefore I try to get the client id from google api console, and in the api console it shows something like this:

Client ID: 533832195920.apps.googleusercontent.com
Redirect URIs: http://bobyouku.ap01.aws.af.cm/testyoutube.php
https://developers.google.com/oauthplayground

However when I try to test my account using the following URL:

https://accounts.google.com/o/oauth2/auth?client_id=533832195920.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Fbobyouku.ap01.aws.af.cm%2Ftestyoutube.php&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube&response_type=code&access_type=offline

It gives out the result of invalid_client. Even when I try it on oauth2 playground, same fail occurs

So anyone knows what's happen?

Fennelflower answered 18/6, 2013 at 10:41 Comment(4)
I found that sometimes the oauth2 client id doesn't work. I don't know why, but when I open a new account and create the client id again, it works.Fennelflower
Bob is right, creating the client id solves this problemTapes
Make sure when copy/pasting the client id you don't include a trailing space. That did the trick for me...Campanile
for me, i regenerated client secret and use that it worked. Seems the api is still unstable.Merta
S
116

Set/change your product name, I had this issue until I created a product name as same as project name.

The product name can be set in the Consent screen section of the Google Developers Console for your project. Look under APIs & auth in the left navigation and select Consent screen. You need also to set your email address in the box above the product name.

Sanctuary answered 23/10, 2013 at 8:3 Comment(8)
Thankyou!! I was getting error ""Error: invalid_client. The OAuth client was not found." Wasted several hours today on this, but updated the product name just now and hey-presto, problem fixed. That error is so misleading.Monti
What is the product name?Estevez
It's in the consent screen. You have to fill out the 'PRODUCT NAME' fieldAgonizing
This worked. Just to be succinct: set both 'PRODUCT NAME' AND 'EMAIL ADDRESS' fields.Serapis
That did not work for me. Is it the same name of the app installed and running on the device? I did that. No success!!!Gymnast
Not working for me and no info provided to understand what causes the problemJaxartes
Thanks! Saved my day! And I must say, out of all social providers Google has the worse docs and worst UI. It's so overwhelming and confusing along with their bad navigation. I almost always forget how to go to the project configuration page lol.Adelaadelaida
Such an arbitrary reasonStealer
L
77

After copy values from Google web UI, I had a blank space for:

  • client_id
  • secret

And at the BEGINNING and at the END for both.

This happens even when clicking on the "copy" button.

Lir answered 19/1, 2016 at 21:39 Comment(7)
This issue still persists :PRogerrogerio
Unbelievable, even when clicking the "copy" button in the API console... You'd think Google's developers area would be whitespace sensitive!Polemics
Unbelievable as well here. Delete those extra spaces on both sides of the string. Then if after following all what has been said here and nothing still works, delete the app/project and re-create it again coz there could be caching issues.Zetta
Yeap, the issue still exists!!! Holy crap. I omitted one white space and didn't see it until recheck. Thanks.Thermosphere
darn! I saw the space at the end and removed it but did not check for the space in the beginning.Monica
How come this hasn't been reported? Where the heck I report this stuff?!Korman
Oh my gosh. Thank you SO much. I could have spent hours confused without realizing that I had an extra newline in my environment variable.Lagunas
I
42

Trim the leading and trailing white space from both the client_id and client_secret. Google's copy button does not do this for you.

enter image description here

Set both the email address and product name fields for the OAuth consent screen.

enter image description here

Informal answered 12/7, 2016 at 1:2 Comment(8)
You probably shouldn't leave your client secret exposed in an answer like that.Veinlet
@Veinlet It's a throw away account.Informal
Phew. Had me worried there Shaun :DVeinlet
How did you get to this screen?Sinful
"Throw away account" - not for Google, which tracks you and bundles all accounts you ever used to "associated accounts". And once Google bans one of the accounts - the whole bundle is blocked. Just search for "Google Developer account terminated" on Reddit.Porphyry
Good call @AlexanderFarber... it is better safe than it is sorry especially when the fix is easy.Informal
@ShaunLuttin You do realize your data is still visible in the answer editing history? Just FYISwallowtailed
Good to know. I appreciate that @Mark.Informal
R
16

Setting EMAIL ADDRESS and PRODUCT NAME in the consent screen of Google developer console, solves the error "Error: invalid_client. The OAuth client was not found." for me.

Remonstrance answered 10/9, 2014 at 9:57 Comment(0)
B
9

I had .apps.googleusercontent.com twice in my ID.

It was a copy and paste issue "Your ID HERE".apps.googleusercontent.com

Bolitho answered 28/8, 2015 at 12:0 Comment(1)
Mine was a blank space left on either end :/Cecil
Q
8

invalid_client can also simply means that your client ID and client secret are wrong when you create your Oauth2 object.

Quantize answered 6/6, 2017 at 21:37 Comment(0)
Z
7

in this thread i found my answer.

  1. I went to google console,
  2. generate a new project, made refresh, because in my case after create the page didn't reload
  3. select new project
  4. create a client ID
  5. use it for what you need

thanks guys :D

Zootomy answered 27/5, 2014 at 18:33 Comment(0)
L
6

In my case this turned out to be something else, namely my code used an environment variable that hadn't been set properly (and stupidly wasnt checked by my code). Setting it, recompiling assets, and restarting the app did the trick.

Lavonlavona answered 9/10, 2014 at 19:31 Comment(2)
Same here; I had set it but forgot to restart my terminalSarawak
Updated my batch file from set MY_ENV_VAR='a string' to set MY_ENV_VAR=a string, and the error went away. The extraneous quote strings in the environmental variable were being parsed as part of the string itself.Stylopodium
W
6

If you follow the documentation, from this page https://developers.google.com/identity/sign-in/web/sign-in#specify_your_apps_client_id

you'll see

<meta name="google-signin-client_id" content="YOUR_CLIENT_ID.apps.googleusercontent.com">

But it's wrong. It should be

<meta name="google-signin-client_id" content="YOUR_CLIENT_ID">

The issue is that the '.apps.googleusercontent.com' gets added anyway. If you do it like the documentation says, you get '.apps.googleusercontent.com' twice

Watering answered 27/9, 2018 at 19:57 Comment(2)
Thanks a lot. Changing it as you have suggested did the trick.Schulman
You are right! It worked as you stated.Mameluke
W
5

I solved this by removing unnecessary quotes from my clientID and clientSecret values.

Watermark answered 1/12, 2017 at 10:1 Comment(1)
You sir/maam are a legend! I removed the quotes from my Heroku environment variables.Proselytize
T
2

Did the error also report that it was missing an application name? I had this issue until I created a project name (e.g. "Project X") in the project settings dialog.

Terminus answered 16/7, 2013 at 23:2 Comment(0)
L
2

probably old credentials are invalid

see the answer below

stackoverflow answer

or short names may work

see the answer below stackoverflow answer

or product name same as project name as answered already

at times one may include extra space in the

check twice this line so that you are redirected to the correct url

Legged answered 29/4, 2017 at 6:1 Comment(0)
D
1

I solved my problem with trim :

'google' => [
    'client_id' =>trim('client_id),
    'client_secret' => trim('client_secret'),
    'redirect' => 'http://localhost:8000/login/google/callback',
],
Distraught answered 27/12, 2017 at 11:0 Comment(0)
F
1

None of the following were my issue - I resolved this by opening an incognito window. Something was obviously being cached somewhere, no amount of changing auth client settings helped and there were never any trailing or leading spaces in config values.

Fils answered 21/2, 2018 at 12:5 Comment(0)
D
0

Check your Project name on Google APIs console. you choose another project you created. I was same error. my mistake was choosing diffirent project.

Divulgate answered 19/6, 2013 at 3:33 Comment(0)
L
0

At Credentials Accept requests from these HTTP referrers (web sites) (Optional) Use asterisks for wildcards. If you leave this blank, requests will be accepted from any referrer. Be sure to add referrers before using this key in production. Add . (star dot star) . It work fine for me

Lucania answered 22/12, 2015 at 5:48 Comment(0)
P
0

I accidentally had a value in the Client Secret part of the URL, but Google Credential does not need a Client Secret for Android OAuth 2 Client IDs. Simply leaving the value blank in the URL did the trick for me.

Parade answered 5/3, 2016 at 13:2 Comment(0)
L
0

Steps that worked for me:

  1. Delete credentials that are not working for you
  2. Create new credentials with some NAME
  3. Fill in the same NAME on your OAuth consent screen
  4. Fill in the e-mail address on the OAuth consent screen

The name should be exactly the same.

Lunkhead answered 12/5, 2017 at 8:41 Comment(0)
R
0

Another thing to check:

When you install the GoogleAPIs into a .Net app with NuGet, it will inject a new set of dummy values in your *.config file.

Check that any original values are still in place, and remove dummy entries.

Retrogradation answered 20/12, 2017 at 11:42 Comment(0)
C
0

Deleting client ID and creating new one a couple of times worked for me.

Cope answered 26/3, 2018 at 18:39 Comment(0)
R
0

Mine didn't work because I created it from a button from the documentation. I went again to the project and created another OAuthClientID. It worked. Yes, be careful about the extra spaces on right and left too.

Renzo answered 14/6, 2018 at 6:7 Comment(0)
C
0

For best results make sure you have the complete details as follows:

{"client_id":"282324738-4labcgdsd4nlh34885s2d34tmi.apps.googleusercontent.com","project_id":"abcd23ss-212808","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://www.googleapis.com/oauth2/v3/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"23452-dfgdfgcdfgfd","redirect_uris":["http://localhost:6900/auth/google/callback"],"javascript_origins":["http://localhost:6900"]}

This data is always available for download as JSON from https://console.developers.google.com/apis/credentials/oauthclient/

Circumstance answered 9/8, 2018 at 8:40 Comment(0)
C
0

If you are in Meteor JS, you have to use clientId instead appId:

Since facebook uses appId and google clientId.

ServiceConfiguration.configurations.upsert({
    service: "google"
}, {
    $set: {
        clientId: process.env.OAUTH_GOOGLE_APP_ID,
        loginStyle: "popup",
        secret: process.env.OAUTH_GOOGLE_SECRET
    }
});

I spent some hours to realize over that.

Centiare answered 25/5, 2020 at 23:51 Comment(0)
K
0

I wish I had seen this post before, because there are a lot of things I had to find out trial and error. A lot can go wrong with this. Here's another issue I had:

Whe you specify the Authorised Javascript origins or Authorised redirect URIs, make sure to include your domain with and without www. So https://google.com and https://www.google.com

Also I had uploaded an Application logo. Because of that, the consent screen required a review... which takes forever. Don't upload an Application logo, or be very patient.

Kendra answered 28/5, 2020 at 3:41 Comment(0)
S
0

this could also be because of not using https url.

In other words,this only works with https. It works with http only in localhost

Selfcongratulation answered 8/10, 2021 at 10:20 Comment(0)
D
0

The solution that worked for me was to remove the ' single quotes and remove additional spaces at the end of the client id and secret in the .env file

Detoxify answered 23/2, 2023 at 21:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.