Skip to content

Higher level clients add openid scope, whereas low level ones don't, potentially causing REQUIRED_IDENTITY_MISSING #1359

@multimeric

Description

@multimeric

The higher level ClientApp adds openid as a default scope. This doesn't seem to be documented on the class:

:param scope_requirements: A mapping of resource server to initial scope
requirements.

Also, seemingly you can't even stop it doing that:

>>> globus_sdk.ClientApp(client_id=..., client_secret=...).scope_requirements
>>> {'auth.globus.org': [Scope('openid')]}
>>> globus_sdk.ClientApp(client_id=..., client_secret=..., scope_requirements={}).scope_requirements
{'auth.globus.org': [Scope('openid')]}
>>> globus_sdk.ClientApp(client_id=..., client_secret=..., scope_requirements={globus_sdk.scopes.TransferScopes.resource_server: globus_sdk.scopes.TransferScopes.all}).scope_requirements
{'transfer.api.globus.org': [Scope('urn:globus:auth:scope:transfer.api.globus.org:all')], 'auth.globus.org': [Scope('openid')]}

On the other hand, the lower level globus_sdk.ConfidentialAppAuthClient.oauth2_start_flow is documented as adding this scope by default.

:param requested_scopes: The scopes on the token(s) being requested. Defaults to
``openid profile email urn:globus:auth:scope:transfer.api.globus.org:all``

Unlike ClientApp, you can override this by just passing in a custom scope:

globus_sdk.ConfidentialAppAuthClient(...).oauth2_start_flow(..., requested_scopes=...)

What this means is that if you pass the exact same scopes list to both of these objects, then the ConfidentialAppAuthClient will generate tokens that are not compatible with the ClientApp! This causes a confusing error AuthAPIError: ('POST', 'https://auth.globus.org/v2/oauth2/token', 'Basic', 403, 'REQUIRED_IDENTITY_MISSING', "In order to access 'APP NAME', you need to link an identity from ORG NAME to your account.", 'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx)

Some helpful changes might include:

  • Documenting this openid behaviour in ClientApp
  • Making the two clients consistent in whether they do or don't add openid scopes
  • Add a ClientApp.clear_scope_requirements(). Currently I do ClientApp._scope_requirements = {} to remove the openid scope that I don't want
  • Improve the error message when you have tokens that are valid but whose scopes are mismatched

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionA question or open discussion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions