无法使用 google plus API 进行授权

发布于 2025-01-01 11:51:35 字数 739 浏览 1 评论 0原文

我正在尝试使用 google plus 授权我的应用程序。然而,当我使用人员服务并尝试获取“我”时,我尝试过的所有操作总是给出 404,除非我使用创建 Google+ API 应用程序的用户登录。对于我为什么会出现这种情况没有任何意义。

from httplib2 import Http
from apiclient.discovery import build
credential = gp_client.step2_exchange(request.REQUEST)
http = Http()
http = credential.authorize(http)
service = build("plus", "v1", http=http)
o = service.people().get(userId='me').execute()

当我使用 Google+ 浏览器时也是如此:

http://code.google.com/apis/explorer/#_s=plus&_v=v1&_m=people.get&fields=emails

如果我切换到与用户不公开谁创建了 API,那么我可以获取“我”,但如果我授权其他用户,那么我无法获取“我”。

有什么想法吗?

I am trying to authorize my app using google plus. However, everything I've tried always gives me a 404 when I use the people service and attempt to get 'me', except when I log in with the user who created the Google+ API app. It doesn't make any sense to my why that would be the case.

from httplib2 import Http
from apiclient.discovery import build
credential = gp_client.step2_exchange(request.REQUEST)
http = Http()
http = credential.authorize(http)
service = build("plus", "v1", http=http)
o = service.people().get(userId='me').execute()

The same is also true when I use the Google+ explorer:

http://code.google.com/apis/explorer/#_s=plus&_v=v1&_m=people.get&fields=emails

If I switch to private with the user who created the API, then I can fetch 'me', but if I authorize another user, then I can't fetch 'me'.

Any ideas what is happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤蝉 2025-01-08 11:51:35

终于明白这是什么了。 Google 允许您为应用程序授权任何 Google 帐户。但是,如果授权用户尚未升级到 Google+,则当应用程序发出第一个 Google+ API 请求时,该请求将出现 404。这令人难以置信,因为当我设置 OAuth2WebServerFlow 时,我指定了“plus.me”作为范围。 ..恕我直言,当用户尝试授权此 OAuth 请求时,Google 应该告诉用户升级到 Google+。

gp_client = OAuth2WebServerFlow(
    settings.GOOGLE_PLUS_CONSUMER_ID,
    settings.GOOGLE_PLUS_CONSUMER_SECRET,
    scope='https://www.googleapis.com/auth/plus.me',
)

Finally figured out what this was. Google lets you authorize any google account for an app. However, if the authorizing user hasn't upgraded to Google+, when the app makes its first Google+ API request, the request will 404. This is mind boggling, because when I setup the OAuth2WebServerFlow I specified "plus.me" as the scope... IMHO Google should tell the user to upgrade to Google+ when they try to authorize this OAuth request.

gp_client = OAuth2WebServerFlow(
    settings.GOOGLE_PLUS_CONSUMER_ID,
    settings.GOOGLE_PLUS_CONSUMER_SECRET,
    scope='https://www.googleapis.com/auth/plus.me',
)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文