401. That’s an error. Error: invalid_client The OAuth client was not found
Asked Answered
H

13

36

I am working with Google Drive File Picker by following this Google Drive File Picker Example demo project. I have generated API Key and Client Id. But when I run the project I am getting following error

  1. That’s an error.

Error: invalid_client

The OAuth client was not found.

I have also checked This Google Drive File Picker Example Link but it does not work, Please help me to solve my issue.

invalid_client in google oauth2.

enter image description here

Hallvard answered 25/8, 2015 at 13:49 Comment(5)
Did you authorize with OAuth?Mayce
Yes i did, I have downloaded the demo project and got client id and api key from google console, but still it is not running.Hallvard
open Request details in that imageLindeman
added image of request detail.Hallvard
Did you enable Drive SDK on your project?Endoplasm
S
29

Your client_id is not correct, re-check pls

Scipio answered 27/5, 2019 at 19:23 Comment(2)
client_id seems to include a carriage-returnLeavening
It works for me thnksGlean
A
9

In my case, i mistakenly add a , in the values in my .env files so better check that file

# check the comma at the end
AUTH_CLIENT_SECRET=randomauthsecret,
AUTH_CLIENT_ID=randomclientid, 

That causes the wrong client id value. So just remove the ,. Another thing, also don't enclose them in quotes.

AUTH_CLIENT_SECRET=randomauthsecret
AUTH_CLIENT_ID=randomclientid
Alvertaalves answered 3/10, 2020 at 1:24 Comment(1)
Yeah in my case, I entered client_id where api_key was supposed to be and vice versa and I wasted my 20 minutes. Thanks for saving me some time.Alimentary
G
6

enter image description here

In the following pic, I made with restricted mode in API keys section. This helped me to to remove the display. Hence finally, shown as:

No API keys to display

Try to validate the client_id with those that you created for your project as:

https://console.developers.google.com/google/maps-apis/credentials?folder=&organizationId=&project=saml-281612

The project name, like in my case, it is saml, should match with the project apps as saml to mitigate mismatch_uri error.

This helped me to remove all those errors as:

1. Error 400 : mismatch_uri
2. Error 401 : invalid client_id  
Garnet answered 30/6, 2020 at 19:14 Comment(0)
V
4

you may be getting this error if you are already logged in to a google account on your system so log out of all accounts and then run the code

Vaccaro answered 15/4, 2021 at 5:43 Comment(0)
S
2

It worked for me after I removed the quotation marks I had set in my environment variable

Silage answered 18/10, 2021 at 7:1 Comment(0)
M
2

The problem was how vscode format the code, it leaves spaces within the client_id, so I used atom to write the client_id in the .env file and ran app.js through hyper. It worked.

Mescaline answered 20/6, 2022 at 11:19 Comment(0)
M
1

Also facing the same issue and wasted half an hour, the thing that worked for me was creating a new credential and replacing old credential in code with new.

And then it was working as expected

Miyasawa answered 14/7, 2021 at 10:20 Comment(1)
Brevity is great, but only when brevity is able to achieve a clear and concise answer. This answer lacks any sort of explanation &/or example.Rhombus
C
1

May be values are not correct in .env file for "Client ID" and "Client secret" or mistake of using "," in file.

Congruency answered 4/12, 2022 at 11:32 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Arundinaceous
U
0

I had the same issue sometimes back what helped was adding a space when passing the client id.

Universality answered 3/1, 2022 at 13:8 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Arundinaceous
This was my problem: VS 2022 * performs autoformatting when pasting into code outside "". Part of this formatting is to separate "-" from other characters with space.Collinear
L
0

check if there is a semi-colon or comma at the end of your dotenv(.dotnv) file

AUTH_CLIENT_SECRET=randomauthsecret; AUTH_CLIENT_ID=randomclientid,

Lacy answered 4/7, 2023 at 17:30 Comment(0)
A
0

In my case, I have written client_id in GOOGLE_SECRET and client_secret in GOOGLE_ID, that's why it was not working,

Please recheck your env file

Just a ultimate solution, delete old credentials, and create new

Atomicity answered 12/9, 2023 at 8:33 Comment(0)
P
0

I also had an issue with this, what happened with mine was that I put my clientId and secret key in a string. When I removed the string, it worked perfectly

Perfection answered 5/11, 2023 at 14:33 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Arundinaceous
M
0

I have the same problem but i fixed it with this if you forget to add .env file or .env.local when you clone you should have to add this manually GOOGLE_CLIENT_ID ="your client id" GOOGLE_CLIENT_SECRET="your cleint secret"

Modlin answered 13/11, 2023 at 16:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.