Last active
June 23, 2019 06:18
-
-
Save thameera/ae525aa9b5c9ed0aa776e7d792d75dc9 to your computer and use it in GitHub Desktop.
Perform checkSession to retrieve JWT access tokens during an IdP-initiated login
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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