Amazon web services AWS Cognito-getSessionInBackground在ID令牌需要刷新时失败
我的身份证有效期为一小时。一小时后,当我在服务调用中调用CognitoUser对象上的getSessionInBackground时,我的调用失败。如果前一个ID令牌已过期,这不应该返回新的ID令牌吗?这种行为不能持续地再现,这无助于解决问题——它只发生在某些屏幕上。而且,这似乎只发生在Android中,而不是在iOS中。这种情况发生是因为sdk中的线程不完全安全,这种错误发生在aws sdk版本中Amazon web services AWS Cognito-getSessionInBackground在ID令牌需要刷新时失败,amazon-web-services,aws-cognito,Amazon Web Services,Aws Cognito,我的身份证有效期为一小时。一小时后,当我在服务调用中调用CognitoUser对象上的getSessionInBackground时,我的调用失败。如果前一个ID令牌已过期,这不应该返回新的ID令牌吗?这种行为不能持续地再现,这无助于解决问题——它只发生在某些屏幕上。而且,这似乎只发生在Android中,而不是在iOS中。这种情况发生是因为sdk中的线程不完全安全,这种错误发生在aws sdk版本中 new Thread(new Runnable() { @Override
new Thread(new Runnable() {
@Override
public void run() {
try {
semaphore.acquire();
} catch (InterruptedException e) {
e.printStackTrace();
}
CognitoUser user = userPool.getCurrentUser();
user.getSessionInBackground(new AuthenticationHandler() {
@Override
public void onSuccess(final CognitoUserSession userSession) {
Log.d("Authenticator.java", userSession.getIdToken().getJWTToken().toString());
semaphore.release();
callback.onSuccess(userSession);
}
@Override
public void getAuthenticationDetails(AuthenticationContinuation authenticationContinuation, String UserId) {
semaphore.release();
callback.onNeedsPassword();
}
@Override
public void getMFACode(MultiFactorAuthenticationContinuation continuation) {
semaphore.release();
callback.onNeedsPassword();
}
@Override
public void onFailure(final Exception exception) {
semaphore.release();
callback.onFailure(exception);
}
});
}
}).start();