Description
validate_token_parameters
raises when it get's scopes it didn't ask for
Currently inside of validate_token_parameters if the env var OAUTHLIB_RELAX_TOKEN_SCOPE
isn't set and exception is raised.
But if a user has asked for additional scope in the past (possibly from another flow) it's quite possible that the OAuth server would return more scopes then were asked for, since they are already granted.
How to reproduce
In our particular case, the Accounting package Xero allows you to authorize an app in one flow (that never touches our BE client code) and assigns scope to that user (we'll call that Y
. When they then go through our flow and we ask for X
, we get back X+Y
.
Expected behavior
validate_token_parameters
doesn't raise if extra scope is returned.
Additional context
I can see adding another env var OAUTHLIB_RELAX_EXTRA_TOKEN_SCOPE
if this isn't wanted as global behavior, but globally allowing less scopes when you might be connecting to more then 1 service could break a lot of things.
I'm happy to open this PR and update tests, either with another env var, or changing it to if params.missing_scopes:
Please provide any further context here.
- Are you using OAuth1, OAuth2 or OIDC? OAuth2
- Are you writing client or server side code? client
- If client, what provider are you connecting to? Xero
- Are you using a downstream library, such as
requests-oauthlib
,django-oauth-toolkit
, ...? via requests-oauthlib