Skip to content

Instantly share code, notes, and snippets.

@DavidWells
Forked from pfulop/refresh-token.js
Created August 23, 2020 16:41
Show Gist options
  • Save DavidWells/eb6d1826836a8b47b6c9ffb6f35bb27b to your computer and use it in GitHub Desktop.
Save DavidWells/eb6d1826836a8b47b6c9ffb6f35bb27b to your computer and use it in GitHub Desktop.
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