CognitoIdentityProvider / Client / get_user

get_user#

CognitoIdentityProvider.Client.get_user(**kwargs)#

Gets the user attributes and metadata for a user.

Authorize this action with a signed-in user’s access token. It must include the scope aws.cognito.signin.user.admin.

Note

Amazon Cognito doesn’t evaluate Identity and Access Management (IAM) policies in requests for this API operation. For this operation, you can’t use IAM credentials to authorize requests, and you can’t grant IAM permissions in policies. For more information about authorization models in Amazon Cognito, see Using the Amazon Cognito user pools API and user pool endpoints.

See also: AWS API Documentation

Request Syntax

response = client.get_user(
    AccessToken='string'
)
Parameters:

AccessToken (string) –

[REQUIRED]

A non-expired access token for the user whose information you want to query.

Return type:

dict

Returns:

Response Syntax

{
    'Username': 'string',
    'UserAttributes': [
        {
            'Name': 'string',
            'Value': 'string'
        },
    ],
    'MFAOptions': [
        {
            'DeliveryMedium': 'SMS'|'EMAIL',
            'AttributeName': 'string'
        },
    ],
    'PreferredMfaSetting': 'string',
    'UserMFASettingList': [
        'string',
    ]
}

Response Structure

  • (dict) –

    Represents the response from the server from the request to get information about the user.

    • Username (string) –

      The username of the user that you requested.

    • UserAttributes (list) –

      An array of name-value pairs representing user attributes.

      For custom attributes, you must prepend the custom: prefix to the attribute name.

      • (dict) –

        Specifies whether the attribute is standard or custom.

        • Name (string) –

          The name of the attribute.

        • Value (string) –

          The value of the attribute.

    • MFAOptions (list) –

      This response parameter is no longer supported. It provides information only about SMS MFA configurations. It doesn’t provide information about time-based one-time password (TOTP) software token MFA configurations. To look up information about either type of MFA configuration, use UserMFASettingList instead.

      • (dict) –

        This data type is no longer supported. Applies only to SMS multi-factor authentication (MFA) configurations. Does not apply to time-based one-time password (TOTP) software token MFA configurations.

        • DeliveryMedium (string) –

          The delivery medium to send the MFA code. You can use this parameter to set only the SMS delivery medium value.

        • AttributeName (string) –

          The attribute name of the MFA option type. The only valid value is phone_number.

    • PreferredMfaSetting (string) –

      The user’s preferred MFA setting.

    • UserMFASettingList (list) –

      The MFA options that are activated for the user. The possible values in this list are SMS_MFA and SOFTWARE_TOKEN_MFA.

      • (string) –

Exceptions

  • CognitoIdentityProvider.Client.exceptions.ResourceNotFoundException

  • CognitoIdentityProvider.Client.exceptions.InvalidParameterException

  • CognitoIdentityProvider.Client.exceptions.NotAuthorizedException

  • CognitoIdentityProvider.Client.exceptions.TooManyRequestsException

  • CognitoIdentityProvider.Client.exceptions.PasswordResetRequiredException

  • CognitoIdentityProvider.Client.exceptions.UserNotFoundException

  • CognitoIdentityProvider.Client.exceptions.UserNotConfirmedException

  • CognitoIdentityProvider.Client.exceptions.InternalErrorException

  • CognitoIdentityProvider.Client.exceptions.ForbiddenException