Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
how to refresh amplify token
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