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

ValueError: Please supply either code or authorization_response parameters. #300

Open
rahul3103 opened this issue Nov 20, 2017 · 2 comments

Comments

@rahul3103
Copy link

from requests_oauthlib import OAuth2Session
from requests_oauthlib.compliance_fixes import facebook_compliance_fix

client_id = '2117634981801814'
client_secret = '1f38cd50e4671b2c82d0c827912d2cad'

authorization_base_url = 'https://www.facebook.com/dialog/oauth'
token_url = 'https://graph.facebook.com/oauth/access_token'
redirect_uri = 'http:https://localhost:5000/'     # Should match Site URL


facebook = OAuth2Session(client_id, redirect_uri=redirect_uri)
facebook = facebook_compliance_fix(facebook)

authorization_url, state = facebook.authorization_url(authorization_base_url)
print('Please go here and authorize,', authorization_url)

('Please go here and authorize,', u'https://www.facebook.com/dialog/oauth?response_type=code&client_id=2117634981801814&redirect_uri=http%3A%2F%2Flocalhost%3A5000%2F&state=EhUhnFvilLGsEgJ4gIHAqBbZUmIxGH')

redirect_response = raw_input('http:https://localhost:5000/?code=AQBuWYEa4ohlALbiO_lqhwjvDE8PJnzRana6gDrVwY6YtK0oo1T4tuqO_41sTQKvcWbirMAfrgALF8ijEnxTSYUwlOSqi8Si5ROtvzhOsuvMXJBm3n89UBK28Z5ZvZHaJJHS0dySldcqXmL8K4YScx5AlGL0EgCTvO1hqB6O1t368WB6m-C7gowrzNTH9qdiI_2c4mzu4j9XG0ENIh2bE_CU5zTVXPt9kb4W7Q-MM8loEwUc17XdjV6-1LxQ6QrTxv8EwRxsX6TSoVoWCFuvYfdtaEnmxFiC5Bjg7qzBLc02k_ZYxY_2qR_artYIcjSe5H0&state=Vs3nqCxJNQ99scgiZdsMoHBTB8F6XV#_=_')

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

r = facebook.get('https://graph.facebook.com/me?')
print(r.content)

Getting Error

Traceback (most recent call last):
  File "app.py", line 20, in <module>
    facebook.fetch_token(token_url, client_secret=client_secret, authorization_response=redirect_response)
  File "/home/rahul/.virtualenvs/growthplug/local/lib/python2.7/site-packages/requests_oauthlib/oauth2_session.py", line 192, in fetch_token
    raise ValueError('Please supply either code or '
ValueError: Please supply either code or authorization_response parameters.
@kal8492
Copy link

kal8492 commented Aug 15, 2018

I am Trying to Generate autorization code for google assitance. but getting below error.

Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=395874578717-7g6p1v11bkckk8906bq883uo6ap4hfrd.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fassistant-sdk-prototype+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgcm&state=aFtgk28PNFvgg02lT3goIdLFnS74M2&prompt=consent&access_type=offline Enter the authorization code: Traceback (most recent call last): File "/home/pi/env/bin/google-oauthlib-tool", line 11, in <module> sys.exit(main()) File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 722, in __call__ return self.main(*args, **kwargs) File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 535, in invoke return callback(*args, **kwargs) File "/home/pi/env/lib/python3.5/site-packages/google_auth_oauthlib/tool/__main__.py", line 106, in main creds = flow.run_console() File "/home/pi/env/lib/python3.5/site-packages/google_auth_oauthlib/flow.py", line 364, in run_console self.fetch_token(code=code) File "/home/pi/env/lib/python3.5/site-packages/google_auth_oauthlib/flow.py", line 241, in fetch_token self.client_config['token_uri'], **kwargs) File "/home/pi/env/lib/python3.5/site-packages/requests_oauthlib/oauth2_session.py", line 192, in fetch_token raise ValueError('Please supply either code or ' ValueError: Please supply either code or authorization_response parameters.

When i am trying to generate authorization code manually it shows th Error 5000.
error500

@KushalMandala
Copy link

you are using redirect_uri = "urn:ietf:wg:oauth:2.0:oob","http:https://localhost"
replace that with "http:https://localhost:8080/"

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

3 participants