How to get user attributes (username, email, etc.) using cognito identity id

后端 未结 7 786
不思量自难忘°
不思量自难忘° 2020-12-08 06:28

I have AWS Cognito Identity Pool that is configured with Cognito User Pool as an authentication provider.

Assume I have identity ID of an identity in Cognito Identit

7条回答
  •  情歌与酒
    2020-12-08 07:24

    Use this piece of code

           GetDetailsHandler detailsHandler = new GetDetailsHandler() {
         @Override
         public void onSuccess(CognitoUserDetails cognitoUserDetails) {
            CognitoUserAttributes cognitoUserAttributes=cognitoUserDetails.getAttributes();
            stringStringHashMap=new HashMap<>();
            stringStringHashMap =cognitoUserAttributes.getAttributes();
             userNumber=stringStringHashMap.get("phone_number");
            e1.setText(userNumber);
    
            Log.d("Response"," Inside DEATILS HANDLER");
            // Store details in the AppHandler
            AppHelper.setUserDetails(cognitoUserDetails);
            // Trusted devices?
            handleTrustedDevice();
           // e1.setText(input.getText().toString());
             }
    
             @Override
              public void onFailure(Exception exception) {
            closeWaitDialog();
            showDialogMessage("Could not fetch user details!", AppHelper.formatException(exception), true);
            }
           };
         private void getDetails() {
        AppHelper.getPool().getUser(username).getDetailsInBackground(detailsHandler);
          }  
    

提交回复
热议问题