question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught TypeError: Cannot read property 'getAuthToken' of undefined?

See original GitHub issue
chrome.identity.getAuthToken({ 'interactive': true },
			function(token) {
				if (chrome.runtime.lastError) {
					alert(JSON.stringify(chrome.runtime.lastError));
					} else {
						alert(token);
					}
		});

Here, i am getting the error in first line.

and this the manifest of permission: "permissions": ["identity", "https://www.googleapis.com/", "https://accounts.google.com/", "https://*.googleusercontent.com/","https://*.chromiumapp.org/*", "https://accounts.google.com/o/oauth2/v2/auth"],

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
zdravko61commented, Aug 14, 2020

@jliukai

you have to do it from a background script otherwise it will not work and it will give you chrome identity as undefined.

https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/identity

here in the example in the manifest you have background script defined as main.js this script uses index.html to load the identity script and so it’s working as a backround script. Just check the background scripts docs and how to exchange events between content and background and you will be good.

0reactions
Seamus1989commented, Nov 23, 2022

It may require providing a “key” value in your manifest as well. You can either use the same key as the one you get when you upload your extension to the webstore or try packing an extension to generate a new one (though I couldn’t get this second approach working myself).

it may?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chrome.identity not available/undefined - Stack Overflow
But my Chrome doesn't recognize identity. On the following code in developer tools, I get an error saying "Cannot read property getAuthToken of...
Read more >
chrome.identity.getAuthToken is undefined - Google Groups
Yet whenever I try to invoke the getAuthToken method, I get a TypeError stating that it cannot read the property getAuthToken.
Read more >
chrome.identity - Chrome Developers
Gets an OAuth2 access token using the client ID and scopes specified in the oauth2 section of manifest.json. The Identity API caches access...
Read more >
A brand new website interface for an even better experience!
Uncaught TypeError : Cannot read property 'getAuthToken' of undefined?
Read more >
Google-chrome – Chrome.identity not available/undefined
But my Chrome doesn't recognize identity. On the following code in developer tools, I get an error saying "Cannot read property getAuthToken of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found