我有这个电话(为简洁起见,我删除了错误处理):
chrome.identity.getAuthToken({interactive: true}, function (token) {
let req = new XMLHttpRequest();
req.open('GET', 'https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=' + token);
req.onload = function() {
console.log('this userinfo => ', req.response);
};
req.send();
});
我得到这个记录:
this userinfo => {
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}
],
"code": 403,
"message": "Insufficient Permission"
}
}
我相信我需要将以下内容添加到我的 manifest.json 文件中......
在我有这个之前:
"oauth2": {
"client_id": "5461307462-7gebv03xxx9csfidfg5f6ggxxxrju9374.apps.googleusercontent.com",
"scopes": [
"https://www.googleapis.com/auth/chromewebstore.readonly"
]
},
然后我添加这个:
"oauth2": {
"client_id": "5461307462-7gebv03xxx9csfidfg5f6ggxxxrju9374.apps.googleusercontent.com",
"scopes": [
"https://www.googleapis.com/oauth2/v1/userinfo",
"https://www.googleapis.com/oauth2/v1/userinfo.picture",
"https://www.googleapis.com/auth/chromewebstore.readonly"
]
},
但问题是身份验证方法随后发生了变化。我不再有这种看法:
相反,我得到了一个新的 Chrome 标签,如下所示:
问题是,无论我登录多少次,它总是会反弹回同一个登录选项卡。此外,我无法访问任何其他 Chrome 选项卡,它不断将我弹回同一个 Chrome 身份验证选项卡。这太奇怪了,太糟糕了。
有谁知道可能会发生什么?