requests / requests-oauthlib

OAuthlib support for Python-Requests!
https://requests-oauthlib.readthedocs.org/
ISC License
1.71k stars 422 forks source link

`OAuth2Session` constructor does not inherit or reuse the `client.scope` when a `client` is provided and `scope` is not overridden #408

Closed smarie closed 2 years ago

smarie commented 4 years ago
my_scopes = ['my_scope']
client = LegacyApplicationClient(..., scope=my_scopes)
oauth_session = OAuth2Session(client=client)

assert oauth_session.scope == my_scopes  # <-- AssertError

Unfortunately, in OAuth2Session.refresh_token the self.scope is used

I suggest to create a scope property which would return self._scope if overridden, or self.client.scope otherwise (if client is not None).

I'll propose a PR