Chrome.identity不可用/未定义 [英] Chrome.identity not available/undefined
问题描述
我正在写一个chrome扩展,我试图使用chrome.identity API。但是我的Chrome无法识别身份。
关于开发人员工具中的以下代码,我收到一条错误消息:无法读取未定义的属性getAuthToken:
chrome.identity.getAuthToken({'interactive':false},function(token){
我尝试在控制台中输入chrome.extension,但chrome.identity未定义。
我的manifest.json在权限中有身份,我使用的是最新版本的Chrome v38。是否还有其他需要启用身份API的功能?
我无法使用身份的原因是因为我试图从内容脚本访问它,所以我切换到后台脚本并且它现在可以工作了!感谢Rob!
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?
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!
这篇关于Chrome.identity不可用/未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!