【问题标题】:Can't authorize with google plus API无法使用 google plus API 进行授权
【发布时间】:2012-02-25 13:52:08
【问题描述】:

我正在尝试使用 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 的用户切换到私有,那么我可以获取“我”,但如果我授权另一个用户,那么我无法获取“我”。

有什么想法吗?

【问题讨论】:

  • 显示您定义gp_client的位置

标签: python authorization google-plus google-api-python-client


【解决方案1】:

终于知道这是什么了。 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',
)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-13
    • 2015-12-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多