2017-06-22 19 views
0

私はaws-java-sdk-cognitoidentityを使用してAWS Cognitoを通じて認証を実装しようと利便性を使用するためcognitoauth classes 認証が正常に動作しますが、私はrespondToAuthChallengeResultからAuthenticationResultTypeを取得するときにそれがなぜ起こるか、それはヌルを返しますか?RespondToAuthChallengeResult.getAuthenticationResult()の戻りヌル

サンプル:

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ユーザープールが正しく構成されていないか、コードに問題がありますか?

ありがとうございました。

答えて

0

これは、コンソールまたはAdminCreateUser APIを通じてユーザーを作成したようです。状態が示すように、ユーザはcreate a new passwordにする必要があります。

関連する問題