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

[SDK-1790] use refresh_tokens with multiple audiences #521

Merged
merged 3 commits into from
Jul 14, 2020

Conversation

adamjmcgrath
Copy link
Contributor

@adamjmcgrath adamjmcgrath commented Jul 10, 2020

Description

useRefreshTokens: true should be able to handle to handle multiple audiences, with the caveat that the first time you get an RT for a new audience you will have to rely on the iframe fallback, or if you can't because of ITP, do it interactively via popup.

Updated the playground for easier testing

image

References

See: #512

Testing

An example of using RT with multiple audiences in an ITP enabled browser:

const client = new Auth0Client({
  ...
  audience: 'http://api1/users',
  scope: 'read:users',
});

// get access token for existing audience using RT grant
const accessToken1 = await getTokenSilently({
  audience: 'http://api1/users',
  scope: 'read:users',
  ignoreCache: true,
});

// get access token for a new audience which falls back to iframe, because no RT
try {
  const accessToken1 = await getTokenSilently({
    audience: 'http://api2/books',
    scope: 'read:books'
  }); 
// fails because of ITP
} catch (e) {
  // get's access token and an RT interactively
  const accessToken2 = await getTokenWithPopup({
    audience: 'http://api2/books',
    scope: 'read:books'
  });
}

// Can now get access token with RT grant for the second audience silently
const accessToken3 = await getTokenSilently({
    ignoreCache: true,
    audience: 'http://api2/books',
    scope: 'read:books'
  });
  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not master

@adamjmcgrath adamjmcgrath added CH: Added PR is adding feature or functionality medium labels Jul 10, 2020
@adamjmcgrath adamjmcgrath added this to the vNext milestone Jul 10, 2020
@adamjmcgrath adamjmcgrath requested a review from a team July 10, 2020 17:51
@adamjmcgrath adamjmcgrath reopened this Jul 13, 2020
@adamjmcgrath adamjmcgrath changed the title use refresh_tokens with multiple audiences [SDK-1790] use refresh_tokens with multiple audiences Jul 13, 2020
@adamjmcgrath adamjmcgrath merged commit 82807e3 into master Jul 14, 2020
@adamjmcgrath adamjmcgrath deleted the rt-multiple-audience branch July 14, 2020 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CH: Added PR is adding feature or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants