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
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?