1

I followed the answer given in this question - chrome.identity User Authentication in a Chrome Extension

I installed the extension and copied the key from chrome://extensions and generated a client id enter image description here

enter image description here

After generating client ID and Application Id, I pasted them into manifest.json

My manifest.json -

{

    "name": "Identity test",
    "version": "1",
    "manifest_version": 2,
    "background": {
        "scripts": ["background.js"]
    },  
    "permissions": [
        "identity"
    ],
     "oauth2": {
        "client_id": "575910104810-bip578sprqmaauj7cred8ejsf3cirs95.apps.googleusercontent.com",
        "scopes": [
            "https://www.googleapis.com/auth/userinfo.email"
        ]   
    },   
    "key":"mebmekhndfhnahepihccnkiaifobgdbi"

}

My background.js-

chrome.identity.getAuthToken({
    interactive: true
}, function(token) {
    if (chrome.runtime.lastError) {
        alert(chrome.runtime.lastError.message);
        return;
    }
    var x = new XMLHttpRequest();
    x.open('GET', 'https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=' + token);
    x.onload = function() {
        alert(x.response);
    };
    x.send();
});

But I am getting invalid OAuth2 Client ID.Reason?

Community
  • 1
  • 1
Siddharth
  • 6,966
  • 2
  • 19
  • 34

1 Answers1

2

Your format of the "key" field in the manifest is invalid.

It's not the ID, but a cryptographically signed version of it.

See here or here on how to obtain a correct value.

Xan
  • 74,770
  • 16
  • 179
  • 206