Skip to content

Instantly share code, notes, and snippets.

@thameera
Last active June 23, 2019 06:18
Show Gist options
  • Save thameera/ae525aa9b5c9ed0aa776e7d792d75dc9 to your computer and use it in GitHub Desktop.
Save thameera/ae525aa9b5c9ed0aa776e7d792d75dc9 to your computer and use it in GitHub Desktop.
Perform checkSession to retrieve JWT access tokens during an IdP-initiated login
const validateResults = (err, authResult) => {
if (err) {
// handle error
} else {
const at = authResult.accessToken;
// A naïve check to verify if we received a JWT access token
if (!at || !at.startsWith('eyJ')) {
return renewTokens();
}
// Use the tokens
}
};
const renewTokens = () => auth0.checkSession({ audience: 'https://example.com' }, validateResults);
auth0.parseHash({__enableIdPInitiatedLogin: true }, validateResults);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment