我跟着https://developer.chrome.com/extensions/tut_oauth https://developer.chrome.com/extensions/tut_oauth完全一步一步,但我被困在
https://developer.chrome.com/extensions/tut_oauth#identity_permission https://developer.chrome.com/extensions/tut_oauth#identity_permission
在执行扩展后,我没有获取令牌,而是收到错误:
Unchecked runtime.lastError while running identity.getAuthToken:
OAuth2 request failed: Service responded with error: 'bad request'
请建议导致此错误的可能原因是什么。
tl;dr
如果范围为空,则将范围更新为以下内容,
"oauth2": {
"client_id": "yourExtensionOAuthClientIDWillGoHere.apps.googleusercontent.com",
"scopes":["https://www.googleapis.com/auth/userinfo.email"]
}
正在关注教程的人OAuth2:使用 Google 对用户进行身份验证 https://developer.chrome.com/apps/tut_oauth
如果您遇到此问题,可能是因为现在是 2020 年并且文档尚未更新。
本教程要求您,
在扩展清单中包含“oauth2”字段。将生成的 OAuth 客户端 ID 放置在“client_id”下。现在在“范围”中包含一个空字符串。
{
"name": "OAuth Tutorial FriendBlock",
...
"oauth2": {
"client_id": "yourExtensionOAuthClientIDWillGoHere.apps.googleusercontent.com",
"scopes":[""]
},
...
}
但在调用身份 API 调用以获取令牌之前绝不会更新它。
更新范围,使用以下内容应该可以解决问题,
"scopes": ["https://www.googleapis.com/auth/userinfo.email"]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)