Skip to content

Instantly share code, notes, and snippets.

@pfulop
Last active August 23, 2020 16:41
Show Gist options
  • Save pfulop/1520eb2191a26fd87f15a35e930084b2 to your computer and use it in GitHub Desktop.
Save pfulop/1520eb2191a26fd87f15a35e930084b2 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