doovers
doovers

Reputation: 8675

Access custom attributes for AWS Cognito User

I'm trying to get a custom attribute for a user in Cognito. In the AWS console I can see the custom attribute is set but in iOS when I make the call to AWSCognitoIdentityUser.getDetails().continueOnSuccessWith(block:) the response does not contain the custom attributes. Why would this be and how can I get access to them?

Upvotes: 1

Views: 1356

Answers (1)

Kannaiyan
Kannaiyan

Reputation: 13025

Here is how we accessed all attributed for cognito user.

//var params = {                                                                                                           
//  AccessToken: 'STRING_VALUE'                                                                                            
//};

cognitoidentityserviceprovider.getUser(params, function(err, data) {                                             
        if (err) {                                                                                                         
            callback(null, err);                                                                                           
        } else {                                                                                                           
            callback(null, data);                                                                                          
        }                                                                                                                  
});

Hope it helps.

EDIT1:

Also you need to ensure the custom attributes are with read permissions. If you don't have read permissions, it will not be returned in your request.

Upvotes: 1

Related Questions