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

scope on documentation #396

Open
CrimsonGlory opened this issue Jan 30, 2020 · 1 comment
Open

scope on documentation #396

CrimsonGlory opened this issue Jan 30, 2020 · 1 comment

Comments

@CrimsonGlory
Copy link

libs:

oauthlib                           3.1.0      
requests-oauthlib                  1.3.0 

The following code didn't work as the server replied that scope param was missing:

from oauthlib.oauth2 import BackendApplicationClient
from requests_oauthlib import OAuth2Session
client_id = '<redacted>'
client_secret = '<redacted>'
token_url = 'https://login.microsoftonline.com/<redacted>.onmicrosoft.com/oauth2/token?api-version=2.0'
scope = ['<redacted>']
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)

Changing the last two lines for the following did the trick:

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

So we moved the scope from the constructor to the function. But in the documentation it says:

OAuth 2.0 Session
classrequests_oauthlib.OAuth2Session(client_id=None, client=None, auto_refresh_url=None, auto_refresh_kwargs=None, scope=None, redirect_uri=None, token=None, state=None, token_updater=None, **kwargs)

and

fetch_token(token_url, code=None, authorization_response=None, body=u'', auth=None, username=None, password=None, method=u'POST', timeout=None, headers=None, verify=True, proxies=None, **kwargs)

So in the documentation the scope is on the constructor, but in the implementation it is on the fetch_token function.

Source: https://requests-oauthlib.readthedocs.io/en/latest/api.html#oauth-2-0

@brockpalen
Copy link
Contributor

Can confirm this caused me a lot of issues your bug report solved it for me. Documentation update would be great.

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