Skip to content

Get access token without setting state #857

@epacelli

Description

@epacelli

Checklist

  • I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Describe the problem you'd like to have solved

Currently, getting an access token using the AuthService through either getAccessTokenSilently or getAccessTokenUsingPopup automatically sets the new access token in the AuthState. For most use cases this works fine, but this prevents using the AuthService to get an access token for a secondary account that could be used for account linking.

Describe the ideal solution

An optional parameter on the access token functions to prevent storing the access token would allow for using these functions to retrieve a token for a secondary account, which could then be used to link accounts through the Management API. This would have no impact on existing applications since the behavior would default to storing the token if the parameter is not set.

Alternatives and current workarounds

The AuthState storage is unique to this SDK, so the underlying auth0-spa-js library could be used to implement this behavior alongside the auth0-angular library. However, this would then require managing two libraries and keeping both up to date.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestA feature has been asked for or suggested by the community

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions