AWS CLI version 2, the latest major version of AWS CLI, is now stable and recommended for general use. To view this page for the AWS CLI version 2, click here. For more information see the AWS CLI version 2 installation instructions and migration guide.
[ aws . cognito-idp ]
Requests a history of user activity and any risks detected as part of Amazon Cognito threat protection. For more information, see Viewing user event history .
Amazon Cognito evaluates Identity and Access Management (IAM) policies in requests for this API operation. For this operation, you must use IAM credentials to authorize requests, and you must grant yourself the corresponding IAM permission in a policy.
Learn more
See also: AWS API Documentation
admin-list-user-auth-events
is a paginated operation. Multiple API calls may be issued in order to retrieve the entire data set of results. You can disable pagination by providing the --no-paginate
argument.
When using --output text
and the --query
argument on a paginated response, the --query
argument must extract data from the results of the following query expressions: AuthEvents
admin-list-user-auth-events
--user-pool-id <value>
--username <value>
[--cli-input-json <value>]
[--starting-token <value>]
[--page-size <value>]
[--max-items <value>]
[--generate-cli-skeleton <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
--user-pool-id
(string)
The Id of the user pool that contains the user profile with the logged events.
--username
(string)
The username of the user that you want to query or modify. The value of this parameter is typically your user's username, but it can be any of their alias attributes. Ifusername
isn't an alias attribute in your user pool, this value must be thesub
of a local user or the username of a user from a third-party IdP.
--cli-input-json
(string)
Performs service operation based on the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton
. If other arguments are provided on the command line, the CLI values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally.
--starting-token
(string)
A token to specify where to start paginating. This is the
NextToken
from a previously truncated response.For usage examples, see Pagination in the AWS Command Line Interface User Guide .
--page-size
(integer)
The size of each page to get in the AWS service call. This does not affect the number of items returned in the command's output. Setting a smaller page size results in more calls to the AWS service, retrieving fewer items in each call. This can help prevent the AWS service calls from timing out.
For usage examples, see Pagination in the AWS Command Line Interface User Guide .
--max-items
(integer)
The total number of items to return in the command's output. If the total number of items available is more than the value specified, a
NextToken
is provided in the command's output. To resume pagination, provide theNextToken
value in thestarting-token
argument of a subsequent command. Do not use theNextToken
response element directly outside of the AWS CLI.For usage examples, see Pagination in the AWS Command Line Interface User Guide .
--generate-cli-skeleton
(string)
Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input
, prints a sample input JSON that can be used as an argument for --cli-input-json
. If provided with the value output
, it validates the command inputs and returns a sample output JSON for that command.
--debug
(boolean)
Turn on debug logging.
--endpoint-url
(string)
Override command's default URL with the given URL.
--no-verify-ssl
(boolean)
By default, the AWS CLI uses SSL when communicating with AWS services. For each SSL connection, the AWS CLI will verify SSL certificates. This option overrides the default behavior of verifying SSL certificates.
--no-paginate
(boolean)
Disable automatic pagination. If automatic pagination is disabled, the AWS CLI will only make one call, for the first page of results.
--output
(string)
The formatting style for command output.
--query
(string)
A JMESPath query to use in filtering the response data.
--profile
(string)
Use a specific profile from your credential file.
--region
(string)
The region to use. Overrides config/env settings.
--version
(string)
Display the version of this tool.
--color
(string)
Turn on/off color output.
--no-sign-request
(boolean)
Do not sign requests. Credentials will not be loaded if this argument is provided.
--ca-bundle
(string)
The CA certificate bundle to use when verifying SSL certificates. Overrides config/env settings.
--cli-read-timeout
(int)
The maximum socket read time in seconds. If the value is set to 0, the socket read will be blocking and not timeout. The default value is 60 seconds.
--cli-connect-timeout
(int)
The maximum socket connect time in seconds. If the value is set to 0, the socket connect will be blocking and not timeout. The default value is 60 seconds.
To use the following examples, you must have the AWS CLI installed and configured. See the Getting started guide in the AWS CLI User Guide for more information.
Unless otherwise stated, all examples have unix-like quotation rules. These examples will need to be adapted to your terminal's quoting rules. See Using quotation marks with strings in the AWS CLI User Guide .
To list authorization events for a user
The following admin-list-user-auth-events
example lists the most recent user activity log event for the user diego.
aws cognito-idp admin-list-user-auth-events \
--user-pool-id us-west-2_ywDJHlIfU \
--username brcotter+050123 \
--max-results 1
Output:
{
"AuthEvents": [
{
"EventId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
"EventType": "SignIn",
"CreationDate": 1726694203.495,
"EventResponse": "InProgress",
"EventRisk": {
"RiskDecision": "AccountTakeover",
"RiskLevel": "Medium",
"CompromisedCredentialsDetected": false
},
"ChallengeResponses": [
{
"ChallengeName": "Password",
"ChallengeResponse": "Success"
}
],
"EventContextData": {
"IpAddress": "192.0.2.1",
"City": "Seattle",
"Country": "United States"
}
}
],
"NextToken": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222#2024-09-18T21:16:43.495Z"
}
For more information, see Viewing and exporting user event history in the Amazon Cognito Developer Guide.
AuthEvents -> (list)
The response object. It includes the
EventID
,EventType
,CreationDate
,EventRisk
, andEventResponse
.(structure)
One authentication event that Amazon Cognito logged in a user pool with advanced security features active. Contains user and device metadata and a risk assessment from your user pool.
This data type is a request parameter of AdminListUserAuthEvents .
EventId -> (string)
The event ID.EventType -> (string)
The type of authentication event.CreationDate -> (timestamp)
The date and time when the item was created. Amazon Cognito returns this timestamp in UNIX epoch time format. Your SDK might render the output in a human-readable format like ISO 8601 or a JavaDate
object.EventResponse -> (string)
The event response.EventRisk -> (structure)
The threat evaluation from your user pool about an event. Contains information about whether your user pool detected compromised credentials, whether the event triggered an automated response, and the level of risk.
RiskDecision -> (string)
The action taken by adaptive authentication. IfNoRisk
, your user pool took no action. IfAccountTakeover
, your user pool applied the adaptive authentication automated response that you configured. IfBlock
, your user pool prevented the attempt.RiskLevel -> (string)
The risk level that adaptive authentication assessed for the authentication event.CompromisedCredentialsDetected -> (boolean)
Indicates whether compromised credentials were detected during an authentication event.ChallengeResponses -> (list)
A list of the challenges that the user was requested to answer, for example
Password
, and the result, for exampleSuccess
.(structure)
The responses to the challenge that you received in the previous request. Each challenge has its own required response parameters. The following examples are partial JSON request bodies that highlight challenge-response parameters.
Warning
You must provide a SECRET_HASH parameter in all challenge responses to an app client that has a client secret. Include a
DEVICE_KEY
for device authentication.SELECT_CHALLENGE
"ChallengeName": "SELECT_CHALLENGE", "ChallengeResponses": { "USERNAME": "[username]", "ANSWER": "[Challenge name]"}
Available challenges are
PASSWORD
,PASSWORD_SRP
,EMAIL_OTP
,SMS_OTP
, andWEB_AUTHN
.Complete authentication in the
SELECT_CHALLENGE
response forPASSWORD
,PASSWORD_SRP
, andWEB_AUTHN
:
"ChallengeName": "SELECT_CHALLENGE", "ChallengeResponses": { "ANSWER": "WEB_AUTHN", "USERNAME": "[username]", "CREDENTIAL": "[AuthenticationResponseJSON]"}
See AuthenticationResponseJSON ."ChallengeName": "SELECT_CHALLENGE", "ChallengeResponses": { "ANSWER": "PASSWORD", "USERNAME": "[username]", "PASSWORD": "[password]"}
"ChallengeName": "SELECT_CHALLENGE", "ChallengeResponses": { "ANSWER": "PASSWORD_SRP", "USERNAME": "[username]", "SRP_A": "[SRP_A]"}
For
SMS_OTP
andEMAIL_OTP
, respond with the username and answer. Your user pool will send a code for the user to submit in the next challenge response.
"ChallengeName": "SELECT_CHALLENGE", "ChallengeResponses": { "ANSWER": "SMS_OTP", "USERNAME": "[username]"}
"ChallengeName": "SELECT_CHALLENGE", "ChallengeResponses": { "ANSWER": "EMAIL_OTP", "USERNAME": "[username]"}
SMS_OTP
"ChallengeName": "SMS_OTP", "ChallengeResponses": {"SMS_OTP_CODE": "[code]", "USERNAME": "[username]"}
EMAIL_OTP
"ChallengeName": "EMAIL_OTP", "ChallengeResponses": {"EMAIL_OTP_CODE": "[code]", "USERNAME": "[username]"}
SMS_MFA
"ChallengeName": "SMS_MFA", "ChallengeResponses": {"SMS_MFA_CODE": "[code]", "USERNAME": "[username]"}
PASSWORD_VERIFIERThis challenge response is part of the SRP flow. Amazon Cognito requires that your application respond to this challenge within a few seconds. When the response time exceeds this period, your user pool returns a
NotAuthorizedException
error."ChallengeName": "PASSWORD_VERIFIER", "ChallengeResponses": {"PASSWORD_CLAIM_SIGNATURE": "[claim_signature]", "PASSWORD_CLAIM_SECRET_BLOCK": "[secret_block]", "TIMESTAMP": [timestamp], "USERNAME": "[username]"}
Add
"DEVICE_KEY"
when you sign in with a remembered device.CUSTOM_CHALLENGE
"ChallengeName": "CUSTOM_CHALLENGE", "ChallengeResponses": {"USERNAME": "[username]", "ANSWER": "[challenge_answer]"}
Add
"DEVICE_KEY"
when you sign in with a remembered device.NEW_PASSWORD_REQUIRED
"ChallengeName": "NEW_PASSWORD_REQUIRED", "ChallengeResponses": {"NEW_PASSWORD": "[new_password]", "USERNAME": "[username]"}
To set any required attributes that
InitiateAuth
returned in anrequiredAttributes
parameter, add"userAttributes.[attribute_name]": "[attribute_value]"
. This parameter can also set values for writable attributes that aren't required by your user pool.Note
In a
NEW_PASSWORD_REQUIRED
challenge response, you can't modify a required attribute that already has a value. InRespondToAuthChallenge
, set a value for any keys that Amazon Cognito returned in therequiredAttributes
parameter, then use theUpdateUserAttributes
API operation to modify the value of any additional attributes.SOFTWARE_TOKEN_MFA
"ChallengeName": "SOFTWARE_TOKEN_MFA", "ChallengeResponses": {"USERNAME": "[username]", "SOFTWARE_TOKEN_MFA_CODE": [authenticator_code]}
DEVICE_SRP_AUTH
"ChallengeName": "DEVICE_SRP_AUTH", "ChallengeResponses": {"USERNAME": "[username]", "DEVICE_KEY": "[device_key]", "SRP_A": "[srp_a]"}
DEVICE_PASSWORD_VERIFIER
"ChallengeName": "DEVICE_PASSWORD_VERIFIER", "ChallengeResponses": {"DEVICE_KEY": "[device_key]", "PASSWORD_CLAIM_SIGNATURE": "[claim_signature]", "PASSWORD_CLAIM_SECRET_BLOCK": "[secret_block]", "TIMESTAMP": [timestamp], "USERNAME": "[username]"}
MFA_SETUP
"ChallengeName": "MFA_SETUP", "ChallengeResponses": {"USERNAME": "[username]"}, "SESSION": "[Session ID from VerifySoftwareToken]"
SELECT_MFA_TYPE
"ChallengeName": "SELECT_MFA_TYPE", "ChallengeResponses": {"USERNAME": "[username]", "ANSWER": "[SMS_MFA or SOFTWARE_TOKEN_MFA]"}
For more information about
SECRET_HASH
, see Computing secret hash values . For information aboutDEVICE_KEY
, see Working with user devices in your user pool .This data type is a request parameter of RespondToAuthChallenge and AdminRespondToAuthChallenge .
ChallengeName -> (string)
The type of challenge that your previous authentication request returned in the parameterChallengeName
, for exampleSMS_MFA
.ChallengeResponse -> (string)
The set of key-value pairs that provides a response to the requested challenge.EventContextData -> (structure)
The user context data captured at the time of an event request. This value provides additional information about the client from which event the request is received.
IpAddress -> (string)
The source IP address of your user's device.DeviceName -> (string)
The user's device name.Timezone -> (string)
The user's time zone.City -> (string)
The user's city.Country -> (string)
The user's country.EventFeedback -> (structure)
The UpdateAuthEventFeedback or AdminUpdateAuthEventFeedback feedback that you or your user provided in response to the event. A value of
Valid
indicates that you disagreed with the level of risk that your user pool assigned, and evaluated a session to be valid, or likely safe. A value ofInvalid
indicates that you agreed with the user pool risk level and evaluated a session to be invalid, or likely malicious.FeedbackValue -> (string)
The authentication event feedback value. When you provide aFeedbackValue
value ofvalid
, you tell Amazon Cognito that you trust a user session where Amazon Cognito has evaluated some level of risk. When you provide aFeedbackValue
value ofinvalid
, you tell Amazon Cognito that you don't trust a user session, or you don't believe that Amazon Cognito evaluated a high-enough risk level.Provider -> (string)
The submitter of the event feedback. For example, if you submit event feedback in the Amazon Cognito console, this value isAdmin
.FeedbackDate -> (timestamp)
The date that you or your user submitted the feedback.
NextToken -> (string)
The identifier that Amazon Cognito returned with the previous request to this operation. When you include a pagination token in your request, Amazon Cognito returns the next set of items in the list. By use of this token, you can paginate through the full list of items.