Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to disable the use of silent auth when using Refresh Tokens #907

Merged
merged 12 commits into from
May 24, 2022

Conversation

frederikprijck
Copy link
Member

@frederikprijck frederikprijck commented May 19, 2022

When using our SDK in environments such as electron, where it's common to use the file: protocol, using silent auth (iframes) isn't supported. This is because of the fact that electron will set the window's origin to file://, which is a value not supported by Auth0.

This PR adds a flag, useRefreshTokensFallback, that, when set to false, allows disabling the use of silent auth when using Refresh Tokens. The flag defaults to true.

The implication here is that, as we won't fall back to iframes, the errors regarding refresh tokens (missing_refresh_token or invalid_grant) will be thrown to the end-user, needing them to catch these errors and send the user through an interactive login.

let token: string;
try {
  token = await auth0.getTokenSilently();
} catch (e) {
  if (e.error === 'missing_refresh_token' || e.error === 'invalid_grant') {
    auth0.loginWithRedirect();
  }
}

@frederikprijck frederikprijck requested a review from a team as a code owner May 19, 2022 08:15
src/Auth0Client.ts Show resolved Hide resolved
src/global.ts Outdated Show resolved Hide resolved
src/global.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants