通过Python库使用OAuth与request-oauthlib一起抛出异常MissingCodeError

时间:2014-01-16 21:15:35

标签: python oauth google-oauth python-requests

我正在使用Python库requests-oauthlib来创建一个可以将OAuth用于某些主要提供商(Google,Dropbox,Facebook,Twitter)的应用。
提供的示例代码here给了我一个例外:

raise MissingCodeError("Missing code parameter in response.")
oauthlib.oauth2.rfc6749.errors.MissingCodeError: Missing code parameter in response.

问题出现在我使用Google API控制台创建的Web应用程序客户端中,因为我编写了另一段代码执行相同的操作,但使用了Python库google-api-python-client,它可以工作。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

我的错误!

我很困惑,因为使用:

google.fetch_token(token_url, client_secret=client_secret, authorization_response=redirect_response)

要求redirect_response是一个完整的网址。 使用时:

google.fetch_token(token_url, client_secret=client_secret,
... code=redirect_response)

要求redirect_response只是Google回复的代码。