program tip

Google oauth2의 invalid_client

radiobox 2020. 9. 20. 09:24
반응형

Google oauth2의 invalid_client


YouTube 동영상 업로드를위한 웹 페이지를 만들려고하므로 Google API 콘솔에서 클라이언트 ID를 가져 오려고하는데 API 콘솔에 다음과 같은 내용이 표시됩니다.

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

그러나 다음 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

invalid_client의 결과를 제공합니다. oauth2 놀이터에서 시도해도 같은 실패가 발생합니다.

그래서 무슨 일이 일어나는지 아는 사람이 있습니까?


제품 이름 설정 / 변경, 프로젝트 이름과 동일한 제품 이름을 만들 때까지이 문제가 발생했습니다.

제품 이름은 프로젝트에 대한 Google Developers Console의 동의 화면 섹션에서 설정할 수 있습니다. 왼쪽 탐색 메뉴의 API 및 인증 아래에서 동의 화면을 선택합니다. 또한 제품 이름 위의 상자에 이메일 주소를 설정해야합니다.


Google 웹 UI에서 값을 복사 한 후 다음을위한 공백이 생겼습니다.

  • client_id
  • secret

그리고 BEGINNINGEND 에서 둘 다.


모두에서 선행 및 후행 공백 트림 client_idclient_secret. Google의 복사 버튼은이 작업을 수행하지 않습니다.

여기에 이미지 설명 입력

OAuth 동의 화면에 대한 이메일 주소와 제품 이름 필드를 모두 설정합니다.

여기에 이미지 설명 입력


Google 개발자 콘솔의 동의 화면에서 EMAIL ADDRESS 및 PRODUCT NAME을 설정하면 "오류 : invalid_client. OAuth 클라이언트를 찾을 수 없습니다."오류가 해결됩니다. 나를 위해.


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

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


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


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


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.


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


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.


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


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


I solved my problem with trim :

'google' => [
    'client_id' =>trim('client_id),
    'client_secret' => trim('client_secret'),
    'redirect' => 'http://localhost:8000/login/google/callback',
],

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


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


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.


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.


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.


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.


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


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.


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/

참고URL : https://stackoverflow.com/questions/17166848/invalid-client-in-google-oauth2

반응형