Skip to content

validate_token_parameters should only error if there are missing scopes #888

Open
@justmobilize

Description

@justmobilize

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy