Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome.identity not available/undefined

Tags:

I am writing a chrome extension in which I am trying to use the chrome.identity API. But my Chrome doesn't recognize identity.

On the following code in developer tools, I get an error saying "Cannot read property getAuthToken of undefined:

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

I tried typing in the console. chrome.extension works but chrome.identity is undefined.

My manifest.json has "identity" in permissions. I am on latest Chrome v38. Is there anything else required to enable the identity API?

like image 219
Bonton255 Avatar asked Oct 16 '14 08:10

Bonton255


1 Answers

The reason I was not able to use identity was because I was trying to access it from a content script. I switched to a background script and it works now! Thanks Rob!

PS! You also need to have "permissions": ["identity"] set in your manifest.json.

like image 132
Bonton255 Avatar answered Sep 22 '22 18:09

Bonton255