Search code examples
androidamazon-web-servicesamazon-cognito

How to get AWS Cognito user email attributes in android?


I am new to Android and Amazon Web Services. I am trying to fetch AWS Cognito user attributes from my android app. I found that I can use the method getDetailsHandler to get the list of user attributes. But how can I map my IdentityProvider(this is what I have after the user is logged in) to this getDetailsHandler?

Thanks in advance.


Solution

  • The handler is more of a callback, it gives you a chance to handle errors or utilize the response. The developer guide has a sample on how to do this, but the gist is you need to call it with the user that has signed in:

    user.getDetails(getDetailsHandler);
    

    And you can get the user like this:

    CognitoUserPool userPool = new CognitoUserPool(context, userPoolId, clientId, clientSecret);
    ...
    CognitoUser user = userPool.getCurrentUser();