0
我嘗試使用aws-java-sdk-cognitoidentity通過AWS Cognito來實現身份驗證和方便使用cognitoauth classes 認證工作正常,但當我得到AuthenticationResultType從respondToAuthChallengeResult它返回空爲什麼出現這種情況?RespondToAuthChallengeResult.getAuthenticationResult()返回null
樣品:
AWSCryptoSettings cryptoParams = new AWSCryptoSettings();
AWSCognitoSession clientSession = new AWSCognitoSession(
cryptoParams, "test", "123456", USER_POOL_ID);
AWSCognitoIdentityProvider provider = AWSCognitoIdentityProviderClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(new AnonymousAWSCredentials()))
.withRegion(Regions.EU_WEST_1)
.build();
InitiateAuthRequest authRequest = new InitiateAuthRequest()
.withAuthFlow(AuthFlowType.USER_SRP_AUTH)
.withClientId(CLIENT_APP_ID)
.withAuthParameters(clientSession.step1()); //step1() return Map<String,String> with parameters for auth in it
//Respond to authentication challenge
InitiateAuthResult authResult = provider.initiateAuth(authRequest);
Map<String, String> params = authResult.getChallengeParameters();
Map<String, String> srpAuthResponses = clientSession.step2(params); //step2() return also Map<String, String> with formatted parameters.
RespondToAuthChallengeRequest respondToAuthChallengeRequest = new RespondToAuthChallengeRequest()
.withChallengeName(authResult.getChallengeName())
.withClientId(CLIENT_APP_ID)
.withChallengeResponses(srpAuthResponses);
RespondToAuthChallengeResult respondToAuthChallengeResult = provider.respondToAuthChallenge(respondToAuthChallengeRequest);
//debug
System.out.println(respondToAuthChallengeResult.getChallengeName());
System.out.println(respondToAuthChallengeResult.getChallengeParameters());
System.out.println(respondToAuthChallengeResult.getAuthenticationResult());
AuthenticationResultType authenticationResultType = respondToAuthChallengeResult.getAuthenticationResult(); //there null is retruned;
輸出從SOUT是:
NEW_PASSWORD_REQUIRED
{userAttributes = { 「電子郵件」: 「[email protected]」},requiredAttributes = [] }
null
I請不要正確配置用戶池或代碼中的錯誤?
謝謝。