1

I have this call (I removed error-handling for brevity's sake):

chrome.identity.getAuthToken({interactive: true}, function (token) {

 let req = new XMLHttpRequest();
    req.open('GET', 'https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=' + token);
    req.onload = function() {
      console.log('this userinfo => ', req.response);
    };
    req.send();  

});

I get this logged:

this userinfo =>  {
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "insufficientPermissions",
    "message": "Insufficient Permission"
   }
  ],
  "code": 403,
  "message": "Insufficient Permission"
 }
}

I believe that I need to add the following to my manifest.json file...

before I have this:

  "oauth2": {
    "client_id": "5461307462-7gebv03xxx9csfidfg5f6ggxxxrju9374.apps.googleusercontent.com",
    "scopes": [
      "https://www.googleapis.com/auth/chromewebstore.readonly"
    ]
  },

then I add this:

  "oauth2": {
    "client_id": "5461307462-7gebv03xxx9csfidfg5f6ggxxxrju9374.apps.googleusercontent.com",
    "scopes": [
      "https://www.googleapis.com/oauth2/v1/userinfo",
      "https://www.googleapis.com/oauth2/v1/userinfo.picture",
      "https://www.googleapis.com/auth/chromewebstore.readonly"
    ]
  },

the problem though, is that the authentication method then changes. I no longer get this view:

enter image description here

instead I get a new Chrome tab that looks like this:

enter image description here

the problem is, no matter how many times I login, it always bounces back to the same login tab. Furthermore, I cannot access any other Chrome tab, it keeps bouncing me back to the same Chrome auth tab. It's so weird and such an awful experience.

Does anyone know what might be going on?

Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
  • Did you enable all the related APIs for your project in Google APIs Console? Were you signed into Google Chrome before calling `chrome.identity.getAuthToken`? – Iván Nokonoko Feb 05 '18 at 14:08
  • @IvánNokonoko perhaps I need to enable those APIs? Do you know how to do that? I am not signed in before calling `chrome.identity.getAuthToken()`, to my knowlege. – Alexander Mills Feb 05 '18 at 21:20

1 Answers1

1

Most likely, the problem is that the scopes you request have invalid addresses (where did you get them from?)

Try changing: https://www.googleapis.com/oauth2/v1/userinfo

by: https://www.googleapis.com/auth/userinfo.email and/or https://www.googleapis.com/auth/userinfo.profile

Maybe the scope https://www.googleapis.com/auth/userinfo works as well.

You can also check the useful Google APIs Explorer.

Iván Nokonoko
  • 4,888
  • 2
  • 19
  • 27
  • thanks, do you know what Google API I might need to enable in the Google Developer Console? – Alexander Mills Feb 05 '18 at 22:00
  • I see about 50 potential APIs to enable, but I can't figure out which API might pertain to my issue. – Alexander Mills Feb 05 '18 at 22:01
  • @AlexanderMills Maybe you don't need to enable any API for the scopes you use. Try with the correct scope address first. – Iván Nokonoko Feb 05 '18 at 22:03
  • Hi Ivan, using this in scopes: `https://www.googleapis.com/auth/userinfo`, gave me the exact same problem. Super annoying. Also I cannot figure out which Google API to enable in the Google Developers Console. – Alexander Mills Feb 05 '18 at 23:01
  • Ok so, this works in scopes `https://www.googleapis.com/auth/userinfo.profile`, but this didn't work `https://www.googleapis.com/auth/userinfo`. It looks like it's using OAuth instead of OAuth2? – Alexander Mills Feb 05 '18 at 23:05