Ole Albers
Ole Albers

Reputation: 9315

chrome.identity.getAuthToken cannot get Token in Chrome Extension

I use the following code in a Chrome Extension:

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

This works fine at home with my extension added directly as source folder, but does not work with the packaged CRX-File on another machine (but the same user). I receive "undefined" as a token.

The manifest.json inside the crx contains a Key as needed. This is the relevant part of it:

{    
    "permissions": [
        "http://ajax.googleapis.com/",
        "storage",
        "identity"
    ],

    "key": "xxxxxxxx",
"oauth2": {
   "client_id": "xxxxx.apps.googleusercontent.com",
    "scopes": [
      "https://www.googleapis.com/auth/plus.login",      
      "https://www.googleapis.com/auth/plus.me"
    ]
  }

No Error can be seen on the console when trying to collect the token

No Popup asking for authorization appears at all. No Popup-blocker installed

UPDATE: It looks like the application ID is not the same as the one from the api-dashboard (and the store). (I now have the extension twice installed. One (older version) with the correct ID from the store and one from the CRX) Can I modify the value for the crx?

Upvotes: 2

Views: 1928

Answers (1)

Bill Hoag
Bill Hoag

Reputation: 697

I am also looking into this problem (running dev version on a chromebook) and here's what I understand and worked for me...

When the CRX is created with Pack extension (chrome://extensions), it uses the client id (from Dev Console OAuth) in your manifest, and there is a dependency on the location of the CRX sources.

To install the CRX is manually on another machine, either:

  • Ensure the CRX is installed to the same location (directory) on the target machine, or
  • Use Dev Console to create a new OAuth client id (entering the app id shown in chrome://extensions on the target machine), update manifest.json with the new OAuth client id, recreate the CRX with Pack Extension, and try using the new CRX on the target machine.

Upvotes: 4

Related Questions