-
-
Save DavidWells/eb6d1826836a8b47b6c9ffb6f35bb27b to your computer and use it in GitHub Desktop.
how to refresh amplify token
This file contains 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 refreshToken = async () => { | |
const refreshPromise = new Promise(async (resolve) => { | |
const user = await Auth.currentAuthenticatedUser(); | |
const session = await Auth.currentSession(); | |
user.refreshSession(session.refreshToken, async (res, newSession) => { | |
if (newSession) { | |
await Auth.currentUserCredentials(); | |
} | |
resolve('ok'); | |
}); | |
}); | |
await refreshPromise; | |
}; | |
await refreshToken(); | |
const user = await Auth.currentAuthenticatedUser(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment