简体   繁体   English

通过Python库request-oauthlib将OAuth与Google结合使用会引发MissingCodeError异常

[英]Using OAuth with Google thru the Python library requests-oauthlib throws the exception MissingCodeError

I'm using the Python library requests-oauthlib in order to create an app which can use OAuth with some main providers (Google, Dropbox, Facebook, Twitter). 我使用Python库request-oauthlib来创建可以与一些主要提供程序(Google,Dropbox,Facebook,Twitter)一起使用OAuth的应用。
The example code provided here gives me an exception: 此处提供的示例代码给了我一个例外:

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

The problem is not in the web application client that I created with the Google API console, because I wrote another piece of code doing the same thing but using the Python library google-api-python-client and it works. 问题不在于我使用Google API控制台创建的Web应用程序客户端中,因为我编写了另一段代码,但使用Python库google-api-python-client做同样的事情,并且可以正常工作。

Any idea? 任何想法?

My mistake! 我的错!

I got confused because using: 我很困惑,因为使用:

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

it is required that redirect_response is a full url. 要求redirect_response为完整网址。 While using: 使用时:

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

it is required that redirect_response is only the code replied by Google. 要求redirect_response仅是Google答复的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM