Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

chrome.identity.getAuthToken is undefined

1,298 views
Skip to first unread message

Dimu Designs

unread,
Jan 12, 2017, 1:17:17 PM1/12/17
to Chromium-Extensions-Announce

The chrome.identity module doesn't appear to exist when I to call its getAuthToken method from a content script in my extension. 


I've checked and triple-checked my manifest to ensure it has the correct key, permissions etc. I've created a Google Console project and set its app id to that of the extension and referenced the appropriate scopes and clientids. Yet whenever I try to invoke the getAuthToken method, I get a TypeError stating that it cannot read the property getAuthToken.

While troubleshooting I did some code inspection using the Dev Tools console and found that, while the chrome namespace exists, the identity module is not defined on it (hence my inability to call getAuthToken).

I'm pretty much at my wits end. Can anyone help? 

Samples of my manifest and a screenshot of my console below:

{
    "manifest_version": 2,
    "name": "xxxxx",
    "version": "0.1.9",

    "description": "xxxxx",
    "icons":{
        "16": "icon16x16.png",
        "32": "icon32x32.png",
        "48": "icon48x48.png",
        "64": "icon64x64.png",
        "128": "icon128x128.png",
        "256": "icon256x256.png"
    },

    "permissions": [
        "identity",
        "cookies",
        "webRequest",
        "*://mail.google.com/",
        "*://script.googleapis.com/",
        "*://apis.google.com/"
    ],

    "content_scripts": [
        {
            "js": [
                "init.js"
            ]
        }
    ],
    "oauth2":{
        "client_id": "xxxxx",
        "scopes":[
        ]
    },
    "content_security_policy": "script-src 'self' https://*.google.com https://deason-garner-db.firebaseapp.com; object-src 'self'",
    "key": "xxxxx"
}

















Dimu Designs

unread,
Jan 12, 2017, 4:09:57 PM1/12/17
to Chromium-Extensions-Announce
Turns out that Content scripts don't have access to the chrome identity apis...I have to use the messaging system to call a background script which has access to that api.
Reply all
Reply to author
Forward
0 new messages