requests_oauthlib : scope has been changed from “” to “” in github authentication
requests_oauthlib : scope has been changed from “” to “” in github authentication
I am authenticating a user with github using requests_oauthlib. I have asked for a few permissions in authorization url and it works perfectly. But when I try to fetch the token with the same scope then it gives warning that the scope has been changed. Below is my code.
@github_bp.route('/login')
def login():
bb = OAuth2Session(client_id, scope = scope)
authorization_url, state = bb.authorization_url(authorization_base_url)
session['oauth_state'] = state
return redirect(authorization_url)
@github_bp.route('/callback', methods=['GET'])
def callback():
if 'auth_token_github' not in session:
bb = OAuth2Session(client_id, state = session['oauth_state'], scope = scope)
session['auth_token_github'] = bb.fetch_token(token_url, client_secret = client_secret, authorization_response = request.url)
return redirect(url_for('github.index'))
traceback
Traceback (most recent call last):
File "/user/.local/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "/user/.local/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/user/.local/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/user/.local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/user/.local/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/user/.local/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/user/.local/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/user/.local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/user/.local/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/user/.local/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/user/github/auth.py", line 40, in callback
session['auth_token_github'] = bb.fetch_token(token_url, client_secret = client_secret, authorization_response = request.url)
File "/user/.local/lib/python3.6/site-packages/requests_oauthlib/oauth2_session.py", line 244, in fetch_token
self._client.parse_request_body_response(r.text, scope=self.scope)
File "/user/.local/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 411, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File "/user/.local/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 379, in parse_token_response
validate_token_parameters(params)
File "/user/.local/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 409, in validate_token_parameters
raise w
Warning: Scope has changed from "repo admin:org" to "admin:org,repo".
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Comments
Post a Comment