Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing code parameter while fetching token for Google #308

Open
bdesbiolles opened this issue Mar 6, 2018 · 1 comment
Open

Missing code parameter while fetching token for Google #308

bdesbiolles opened this issue Mar 6, 2018 · 1 comment

Comments

@bdesbiolles
Copy link

Hello,

I followed the Google Oauth2 example and I managed to get the authorization code
but fetching the token I have the following error:

Traceback (most recent call last):
File "/home/baptiste/Code/Databerries/iap_script/user_auth.py", line 28, in
authorization_response=redirect_response)
File "/home/baptiste/.virtualenvs/iap_script/lib/python3.6/site-packages/requests_oauthlib/oauth2_session.py", line 187, in fetch_token
state=self._state)
File "/home/baptiste/.virtualenvs/iap_script/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/clients/web_application.py", line 174, in parse_request_uri_response
response = parse_authorization_code_response(uri, state=state)
File "/home/baptiste/.virtualenvs/iap_script/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 227, in parse_authorization_code_response
raise MissingCodeError("Missing code parameter in response.")
oauthlib.oauth2.rfc6749.errors.MissingCodeError: (missing_code) Missing code parameter in response.

It seems that for Google the parameter is named approvalCode.

@pd-Shah
Copy link

pd-Shah commented Mar 3, 2019

I had the same issue, just change

From

 # Fetch the access token
google.fetch_token(token_url, client_secret=client_secret,
                    authorization_response=redirect_response)

TO

 # Fetch the access token
google.fetch_token(token_url, client_secret=client_secret,
                   code=redirect_response)

although add this:

os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'

and here just pass the code, like: 4/AgGw7I2EJZ43uGI7wvVY1Oc0Pv2s9DsD.......qdT0CY, not the url.

redirect_response = input('Paste the full redirect URL here:\n')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants