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

fix: explicitly add scope to OAuth2Session.prepare_request_body #556

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

prithvidasgupta
Copy link

@prithvidasgupta prithvidasgupta commented Sep 19, 2024

The fetch_token function calls the prepare_request_body function. However, it does not pass the scope initialized in the OAuth2Session class constructor. This leads to Missing access token error in cases where the scope is a required parameter. I believe explicitly passing it here makes sense.

This fix may be related to #324

Code used to test

import os
from oauthlib.oauth2 import BackendApplicationClient
from requests_oauthlib import OAuth2Session

client_secret = os.environ['CLIENT_SECRET']
client_id = os.environ['CLIENT_ID']
token_url= os.environ['TOKEN_URL']
scope = ['examplescope']

client = BackendApplicationClient(client_id=client_id)
oauth = OAuth2Session(client=client, scope=scope)
token = oauth.fetch_token(token_url=token_url, client_id=client_id,
        client_secret=client_secret)

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

Successfully merging this pull request may close these issues.

1 participant