user3696321
user3696321

Reputation: 137

Chrome API is undefined

I'm trying to get a Chrome extension that interacts with Dropbox's API, using OAuth2. I have read the Identity API documentation but I am confused on where to invoke chrome.identity.launchWebAuthFlow().

I have created a background page, and included a .js script which calls chrome.identity.launchWebAuthFlow(), but I get undefined when I call console.log(chrome.identity). console.log(chrome) prints an object to console.

Am I misunderstanding something? Do I have to use a listener and invoke that function after something happens?

Upvotes: 1

Views: 1297

Answers (1)

Xan
Xan

Reputation: 77571

In general, if chrome.something is undefined while it should exist, you don't have permissions to use it. Either you need a permission in your manifest, or it cannot be used in the current context (i.e. a content script).

In your case, you must be missing "identity" permission in the manifest. It's specified in the documentation header.

Upvotes: 3

Related Questions