简体   繁体   中英

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).
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.

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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