大家好,我是android应用程序开发人员,我正在为移动应用程序使用认证机制。一旦我验证了我的用户,我就会得到RefreshToken和IDToken。根据亚马逊认知,它在一个小时后过期IDToken。我正在尝试让我的会话再次获得令牌,这是我试图完成它的方法。
String poolId = 'xxxxxx';
String clientId = 'xxxxxx';
String clientSecret = 'xxxxxx';
CognitoUserPool userPool = new CognitoUserPool(context, poolId, clientId, clientSecret,Regions.EU_WEST_1);
CognitoUser user = userPool.getUser();
user.getSessionInBackground(new AuthenticationHandler() {
@Override
public void onSuccess(CognitoUserSession userSession, CognitoDevice newDevice) {
String idToken = userSession.getIdToken().getJWTToken();
Map<String, String> logins = new HashMap<String, String>();
logins.put("cognito-idp." + Constants.REGION + ".amazonaws.com/" + Constants.UserPool, userSession.getIdToken().getJWTToken());
credentialsProvider.setLogins(logins);
credentialsProvider.refresh();
}
@Override
public void getAuthenticationDetails(AuthenticationContinuation authenticationContinuation, String userId) {
Log.i("MQTT","Detail");
}
@Override
public void getMFACode(MultiFactorAuthenticationContinuation continuation) {
Log.i("MQTT","MFACode");
}
@Override
public void authenticationChallenge(ChallengeContinuation continuation) {
Log.i("MQTT","Challenge");
}
@Override
public void onFailure(Exception exception) {
Log.i("MQTT","Fail");
}
});我有userpoolid,我需要知道从哪里可以获得clientID和clientSecret.So,这样我就可以在onSuccess回调中获得数据并获得IDToken。
如果有人能帮上忙,真的很感谢。谢谢
发布于 2019-04-11 14:12:56
现在,您可以记下客户端id和客户端密码。
文档:https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-client-apps.html
https://stackoverflow.com/questions/55625545
复制相似问题