4

I'm trying to use chrome.identity.getAuthToken to get a token, but every time I try this error shows up:

OAuth2 request failed: Service responded with error: 'bad client id: {0}'

I have no idea why this is happening. The client ID I put in manifest.json is exactly the same as the one on the Google Developers Console, and the correct scopes is also included:

oauth2: {
    "client_id": "NUMBERS-NUMBERS&LETTERS.apps.googleusercontent.com",
    "scopes": ["https://www.googleapis.com/auth/SOME_SERVICE"]
}

The extension is up on the webstore, and I don't see why it is still giving the bad client ID error.

What is possibly causing this error? What am I missing here?

Derek 朕會功夫
  • 92,235
  • 44
  • 185
  • 247

3 Answers3

2

Just as a note for myself and for someone run into.

I have encounter this problems with chrome app , the answers is not my problem ,and finally I found the solution for my problem but produce the same error as the question.

As https://developer.chrome.com/apps/app_identity#client_id say is much special for chrome apps, you have to create a separate client id for your chrome app.

Go to the "API Access" navigation menu item and click on the Create an OAuth 2.0 client ID... blue button. Enter the requested branding information, select the Installed application type.

you must to choose Installed application an set you Application ID.

what's your Application ID ? chrome-extension://your application id

chrome-extension://gfmehiepojbflifceoplblionpfclfhf/

Haiyang Xu
  • 101
  • 1
  • 4
1

I overcomed this problem by setting up the email address and product name in "Consent screen" in the Google Developer Console. Please refer to https://developers.google.com/console/help/new/#userconsent for detail.

Shih-Wen Su
  • 2,589
  • 24
  • 21
1

I had a similar problem. Everything seemed to work fine on my own laptop, but when i ran it on another device i got that "bad client id" error.

My problem was that the client-id changed from one device to another, as i did not yet upload my extension to the chrome store.

To overcome that problem, i followed the instructions of How to change chrome packaged app id Or Why do we need key field in the manifest.json?.

You need to create a key to keep the client-id persistent through all devices.

Hope that helps finding the right answer for people with the same issue quicker.

Mauritius
  • 265
  • 1
  • 8
  • 23