我以为我的事情正在滚动,但我发现在使用 interactive:false 调用 getAuthToken 后出现了这个错误:
OAuth2 请求失败:服务响应错误:“错误请求”
'Bad Request' 真的很少告诉我。好的,我知道我可能需要使用 interative:true (为什么?),所以当我尝试这样做时,它会生成我的浏览器,提示我的谷歌登录(我输入它,这真的很痛苦,因为我们有两步身份验证),然后......什么都不做......回调永远不会被调用......
任何有兴趣帮助我的人都可能希望从我的 manifest.json 中查看一些信息:
"key": "MII...QAB",
"oauth2": {
"client_id": "35...-lnf...1pd.apps.googleusercontent.com",
"scopes": [ "identity" ]
},
"permissions":[ "identity", "https://accounts.google.com/*", "https://www.googleapis.com/*", "https://*.amazonaws.com/*", "<all_urls>" ],
您可能还想查看相关代码:
chrome.identity.getAuthToken({ 'interactive': true, 'scopes':['identity'] }, function ( token ) {
if ( chrome.runtime.lastError ) {
next(chrome.runtime.lastError);
} else {
next( null, token );
}
});
或者,或者:
chrome.identity.getAuthToken({ 'interactive': false }, function ( token ) {
if ( chrome.runtime.lastError ) {
next(chrome.runtime.lastError);
} else {
next( null, token );
}
});
我很乐意提供任何其他可能有助于确定我哪里出错的信息。