【发布时间】:2018-07-15 22:01:51
【问题描述】:
我正在开发 Google Chrome 扩展程序。我希望能够使用来自这些端点的数据访问用户个人资料信息:
我似乎无权访问这些资源。从我的网络搜索来看,我可能需要在 Google Developers Console 中启用库 API。但我看了那里,找不到合适的 API 来启用。有谁知道我应该启用哪个 API?
【问题讨论】:
-
在使用
https://www.googleapis.com/oauth2/v1/userinfo的情况下,不需要开启与此相关的API。您可以通过从 OAuth2 进程中检索到的访问令牌来使用端点。当您使用它时,请将https://www.googleapis.com/auth/userinfo.profile包含在范围内。如果此信息对您没有用处,我很抱歉。 -
这是附加信息。作为测试,我在未启用所有 API 的情况下使用它。示例 curl 命令是
curl -H "Authorization: Bearer ### access token ###" "https://www.googleapis.com/oauth2/v1/userinfo"。我确认它有效。令牌的范围只有https://www.googleapis.com/auth/userinfo.profile。关于端点,https://www.googleapis.com/oauth2/v1/userinfo和https://www.googleapis.com/oauth2/v2/userinfo返回相同的信息。 -
你知道OP中两个url有什么区别吗?
-
关于
userinfo,返回相同的信息。 v3也是一样的。似乎除了userinfo之外的端点,版本之间存在差异。 stackoverflow.com/questions/31277898/…
标签: google-chrome-extension google-api google-oauth google-developers-console