Here's how I solved this problem using amazon-cognito-identity-js
const userPool = new CognitoUserPool({
UserPoolId: 'userPoolId',
ClientId: 'userPoolWebClientId',
});
const cognitoIdToken = new CognitoIdToken({
IdToken: idToken,
});
const cognitoAccessToken = new CognitoAccessToken({
AccessToken: accessToken,
});
const cognitoRefreshToken = new CognitoRefreshToken({
RefreshToken: refreshToken,
});
const username = (cognitoIdToken.payload as any).email;
const user = new CognitoUser({
Username: username,
Pool: userPool,
});
user.setSignInUserSession(
new CognitoUserSession({
AccessToken: cognitoAccessToken,
IdToken: cognitoIdToken,
RefreshToken: cognitoRefreshToken,
})
);
Top comments (0)