Last active
August 23, 2020 16:41
-
-
Save pfulop/1520eb2191a26fd87f15a35e930084b2 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