2017-06-21 77 views
0

当我尝试使用android(java)代码登录AWS中的Cognito时,出现Unkown错误。AWS Cognito登录时出现未知错误

public void SignIn(String phoneNumber) { 

    final ClientConfiguration clientConfiguration = new ClientConfiguration(); 

    // Create a CognitoUserPool object to refer to your user pool 
    CognitoUserPool userPool = new CognitoUserPool(_context, poolId, _clientId, 
      _clientSecret, clientConfiguration); 

    CognitoUser user = userPool.getUser(phoneNumber); 

    // Callback handler for the sign-in process 
    AuthenticationHandler authenticationHandler = new AuthenticationHandler() { 

     @Override 
     public void onSuccess(CognitoUserSession cognitoUserSession) { 
      // Sign-in was successful, cognitoUserSession will contain tokens for the user 
      Token = cognitoUserSession.getAccessToken(); 

     } 

     @Override 
     public void getAuthenticationDetails(AuthenticationContinuation authenticationContinuation, String userId) { 
      // The API needs user sign-in credentials to continue 
      AuthenticationDetails authenticationDetails = new AuthenticationDetails(userId, _password, null); 

      // Pass the user sign-in credentials to the continuation 
      authenticationContinuation.setAuthenticationDetails(authenticationDetails); 

      // Allow the sign-in to continue 
      authenticationContinuation.continueTask(); 
     } 

     @Override 
     public void getMFACode(MultiFactorAuthenticationContinuation multiFactorAuthenticationContinuation) { 
      // Multi-factor authentication is required; get the verification code from user 
      multiFactorAuthenticationContinuation.setMfaCode("123"); 
      // Allow the sign-in process to continue 
      multiFactorAuthenticationContinuation.continueTask(); 
     } 

     @Override 
     public void onFailure(Exception exception) { 
      // Sign-in failed, check exception for the cause 
      Log.d("error:", exception.getMessage()); 
      LoginController loginController = new LoginController(_this); 
      loginController.NavigateToLogin(); 

     } 
    }; 

    // Sign in the user 
    user.getSessionInBackground(authenticationHandler); 

} 

我接受了IAM中的所有默认角色。

注册并确认电子邮件正常工作。它只是当我想要登录后认证Continuation.continueTask();它显示未知的错误。有任何想法吗?建议?

回答

0

原来我使用了错误的poolid喔! 联合池中还有一个池ID,我用它代替用户池中的池ID