如果您遇到'Problem refreshing the AWS Cognito ID Token”错误,则有可能是因为您当前应用使用的 AWS Cognito 用户池设置了 JWT 密钥过期时间,但是在过期时间内您尝试刷新了访问令牌。这时候,您受到了'Problem refreshing the AWS Cognito ID Token”错误。
为解决此问题,请参考以下方法:
首先打印 AWS Cognito ID Token,观察其 expiry time。例如:
console.log(YourCognitoToken.expiresIn);
确认 JWT key expiration time 和 AWS Cognito ID Token expiration time 是否一致。如果它们不一致,则请更新 JWT key,以确保两者之间的同步。
如果通过以上步骤的操作仍未解决问题,则可能是因为 AWS Cognito ID Token 在过期后未自动刷新。在这种情况下,请尝试在 AWS Cognito ID Token 到期后手动刷新访问令牌。例如:
AWS.config.credentials.refresh((err) => { if (err) console.error(err); });
通过这些方法,您可以轻松解决'Problem refreshing the AWS Cognito ID Token”的问题。