【问题标题】:Getting OAuth Token from a google service从谷歌服务获取 OAuth 令牌
【发布时间】:2013-07-21 02:40:26
【问题描述】:

我正在尝试通过 gmail 获取当前用户的所有联系人。

我注册了域并在此处获得了这些密钥:https://www.google.com/accounts/ManageDomains

我有一个本地服务器正在运行并响应 oauth_callback_url

`127.0.0.1:8000/google/oauth/cb/`

我在 shell 中尝试下面的代码,看看我是否得到了一个令牌和一个秘密, 以下是我尝试过的代码,后面是我收到的输出:

import oauth2 as oauth, requests

consumer = oauth.Consumer(my_consumer_key, my_consumer_secret)
client = oauth.Client(consumer)
OAUTH_CALLBACK_URL = 'http://%s/google/oauth/cb/' % (request.META.get('HTTP_HOST'))
resp, content = client.request("%s?%s" % (GOOGLE_REQUEST_TOKEN_URL, OAUTH_CALLBACK_URL), method="GET")

输出

In [21]: content
Out[21]: 'parameter_absent\noauth_parameters_absent:scope\n\n'

In [22]: resp
Out[22]: 
{'-content-encoding': 'gzip',
 'cache-control': 'private, max-age=0',
 'content-length': '48',
 'content-type': 'text/plain; charset=UTF-8',
 'date': 'Mon, 22 Jul 2013 11:09:53 GMT',
 'expires': 'Mon, 22 Jul 2013 11:09:53 GMT',
 'server': 'GSE',
 'status': '400',
 'x-content-type-options': 'nosniff',
 'x-xss-protection': '1; mode=block'}

请告诉我,我错过了什么。

【问题讨论】:

    标签: python oauth google-oauth


    【解决方案1】:

    正如在输出中已经可见的那样,缺少范围参数,因此添加范围 URL 会有所帮助。

    联系范围 url 是 - https://www.google.com/m8/feeds/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-10
      • 2016-07-04
      • 1970-01-01
      • 2015-05-17
      • 1970-01-01
      • 2016-05-20
      相关资源
      最近更新 更多