使用python-oauth2我得到oauth_parameters_absent:scope

时间:2011-07-26 13:59:34

标签: python oauth

尝试将python-oauth2用于我的项目,但我得到了:

In [1]: import oauth2 as oauth

In [2]: consumer_key='dijscrape.ep.io'

In [3]: consumer_secret='my-secret-here'

In [4]: REQUEST_TOKEN_URL = 'https://www.google.com/accounts/OAuthGetRequestToken'

In [5]: consumer = oauth.Consumer(consumer_key, consumer_secret)

In [6]: client = oauth.Client(consumer)

In [7]: r, c = client.request(REQUEST_TOKEN_URL, "GET")

In [8]: print r
------> print(r)
{'status': '400', 'x-xss-protection': '1; mode=block', 'x-content-type-options': 'nosniff', 'transfer-encoding': 'chunked', 'expires': 'Tue, 26 Jul 2011 13:38:13 GMT', 'server': 'GSE', 'cache-control': 'private, max-age=0', 'date': 'Tue, 26 Jul 2011 13:38:13 GMT', 'content-type': 'text/plain; charset=UTF-8'}

In [9]: print c
------> print(c)
parameter_absent
oauth_parameters_absent:scope

它可以是什么?

1 个答案:

答案 0 :(得分:2)

Google要求request_token uri的“范围”参数。

http://code.google.com/apis/accounts/docs/OAuth.html#prepScope

类似

scope = "http://www.google.com/calendar/feeds/default/allcalendars/full"
REQUEST_TOKEN_URL = 'https://www.google.com/accounts/OAuthGetRequestToken?scope={0}'.format(scope)

我注意到你没有接受你提出的任何问题的答案。如果答案有帮助,请记住通过单击答案旁边的复选标记来接受答案。