/AWS1/IF_CGP=>ADMININITIATEAUTH()
¶
About AdminInitiateAuth¶
Starts sign-in for applications with a server-side component, for example a traditional web application. This operation specifies the authentication flow that you'd like to begin. The authentication flow that you specify must be supported in your app client configuration. For more information about authentication flows, see Authentication flows.
This action might generate an SMS text message. Starting June 1, 2021, US telecom carriers require you to register an origination phone number before you can send SMS messages to US phone numbers. If you use SMS text messages in Amazon Cognito, you must register a phone number with Amazon Pinpoint. Amazon Cognito uses the registered number automatically. Otherwise, Amazon Cognito users who must receive SMS messages might not be able to sign up, activate their accounts, or sign in.
If you have never used SMS text messages with Amazon Cognito or any other Amazon Web Services service, Amazon Simple Notification Service might place your account in the SMS sandbox. In sandbox mode , you can send messages only to verified phone numbers. After you test your app while in the sandbox environment, you can move out of the sandbox and into production. For more information, see SMS message settings for Amazon Cognito user pools in the Amazon Cognito Developer Guide.
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
Method Signature¶
IMPORTING¶
Required arguments:¶
iv_userpoolid
TYPE /AWS1/CGPUSERPOOLIDTYPE
/AWS1/CGPUSERPOOLIDTYPE
¶
The ID of the user pool where the user wants to sign in.
iv_clientid
TYPE /AWS1/CGPCLIENTIDTYPE
/AWS1/CGPCLIENTIDTYPE
¶
The ID of the app client where the user wants to sign in.
iv_authflow
TYPE /AWS1/CGPAUTHFLOWTYPE
/AWS1/CGPAUTHFLOWTYPE
¶
The authentication flow that you want to initiate. Each
AuthFlow
has linkedAuthParameters
that you must submit. The following are some example flows.
- USER_AUTH
The entry point for choice-based authentication with passwords, one-time passwords, and WebAuthn authenticators. Request a preferred authentication type or review available authentication types. From the offered authentication types, select one in a challenge response and then authenticate with that method in an additional challenge response. To activate this setting, your user pool must be in the Essentials tier or higher.
- USER_SRP_AUTH
Username-password authentication with the Secure Remote Password (SRP) protocol. For more information, see Use SRP password verification in custom authentication flow.
- REFRESH_TOKEN_AUTH and REFRESH_TOKEN
Receive new ID and access tokens when you pass a
REFRESH_TOKEN
parameter with a valid refresh token as the value. For more information, see Using the refresh token.- CUSTOM_AUTH
Custom authentication with Lambda triggers. For more information, see Custom authentication challenge Lambda triggers.
- ADMIN_USER_PASSWORD_AUTH
Server-side username-password authentication with the password sent directly in the request. For more information about client-side and server-side authentication, see SDK authorization models.
Optional arguments:¶
it_authparameters
TYPE /AWS1/CL_CGPAUTHPARAMSTYPE_W=>TT_AUTHPARAMETERSTYPE
TT_AUTHPARAMETERSTYPE
¶
The authentication parameters. These are inputs corresponding to the
AuthFlow
that you're invoking.The following are some authentication flows and their parameters. Add a
SECRET_HASH
parameter if your app client has a client secret. AddDEVICE_KEY
if you want to bypass multi-factor authentication with a remembered device.
- USER_AUTH
USERNAME
(required)
PREFERRED_CHALLENGE
. If you don't provide a value forPREFERRED_CHALLENGE
, Amazon Cognito responds with theAvailableChallenges
parameter that specifies the available sign-in methods.- USER_SRP_AUTH
USERNAME
(required)
SRP_A
(required)- ADMIN_USER_PASSWORD_AUTH
USERNAME
(required)
PASSWORD
(required)- REFRESH_TOKEN_AUTH/REFRESH_TOKEN
REFRESH_TOKEN
(required)- CUSTOM_AUTH
USERNAME
(required)
ChallengeName: SRP_A
(when preceding custom authentication with SRP authentication)
SRP_A: (An SRP_A value)
(when preceding custom authentication with SRP authentication)For more information about
SECRET_HASH
, see Computing secret hash values. For information aboutDEVICE_KEY
, see Working with user devices in your user pool.
it_clientmetadata
TYPE /AWS1/CL_CGPCLIENTMETTYPE_W=>TT_CLIENTMETADATATYPE
TT_CLIENTMETADATATYPE
¶
A map of custom key-value pairs that you can provide as input for certain custom workflows that this action triggers.
You create custom workflows by assigning Lambda functions to user pool triggers. When you use the AdminInitiateAuth API action, Amazon Cognito invokes the Lambda functions that are specified for various triggers. The ClientMetadata value is passed as input to the functions for only the following triggers:
Pre signup
Pre authentication
User migration
When Amazon Cognito invokes the functions for these triggers, it passes a JSON payload, which the function receives as input. This payload contains a
validationData
attribute, which provides the data that you assigned to the ClientMetadata parameter in your AdminInitiateAuth request. In your function code in Lambda, you can process thevalidationData
value to enhance your workflow for your specific needs.When you use the AdminInitiateAuth API action, Amazon Cognito also invokes the functions for the following triggers, but it doesn't provide the ClientMetadata value as input:
Post authentication
Custom message
Pre token generation
Create auth challenge
Define auth challenge
Custom email sender
Custom SMS sender
For more information, see Using Lambda triggers in the Amazon Cognito Developer Guide.
When you use the
ClientMetadata
parameter, note that Amazon Cognito won't do the following:
Store the
ClientMetadata
value. This data is available only to Lambda triggers that are assigned to a user pool to support custom workflows. If your user pool configuration doesn't include triggers, theClientMetadata
parameter serves no purpose.Validate the
ClientMetadata
value.Encrypt the
ClientMetadata
value. Don't send sensitive information in this parameter.
io_analyticsmetadata
TYPE REF TO /AWS1/CL_CGPALYSMETADATATYPE
/AWS1/CL_CGPALYSMETADATATYPE
¶
Information that supports analytics outcomes with Amazon Pinpoint, including the user's endpoint ID. The endpoint ID is a destination for Amazon Pinpoint push notifications, for example a device identifier, email address, or phone number.
io_contextdata
TYPE REF TO /AWS1/CL_CGPCONTEXTDATATYPE
/AWS1/CL_CGPCONTEXTDATATYPE
¶
Contextual data about your user session like the device fingerprint, IP address, or location. Amazon Cognito threat protection evaluates the risk of an authentication event based on the context that your app generates and passes to Amazon Cognito when it makes API requests.
For more information, see Collecting data for threat protection in applications.
iv_session
TYPE /AWS1/CGPSESSIONTYPE
/AWS1/CGPSESSIONTYPE
¶
The optional session ID from a
ConfirmSignUp
API request. You can sign in a user directly from the sign-up process with anAuthFlow
ofUSER_AUTH
andAuthParameters
ofEMAIL_OTP
orSMS_OTP
, depending on how your user pool sent the confirmation-code message.
RETURNING¶
oo_output
TYPE REF TO /aws1/cl_cgpadmininitiateaut01
/AWS1/CL_CGPADMININITIATEAUT01
¶
Domain /AWS1/RT_ACCOUNT_ID Primitive Type NUMC
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->/aws1/if_cgp~admininitiateauth(
io_analyticsmetadata = new /aws1/cl_cgpalysmetadatatype( |string| )
io_contextdata = new /aws1/cl_cgpcontextdatatype(
it_httpheaders = VALUE /aws1/cl_cgphttpheader=>tt_httpheaderlist(
(
new /aws1/cl_cgphttpheader(
iv_headername = |string|
iv_headervalue = |string|
)
)
)
iv_encodeddata = |string|
iv_ipaddress = |string|
iv_servername = |string|
iv_serverpath = |string|
)
it_authparameters = VALUE /aws1/cl_cgpauthparamstype_w=>tt_authparameterstype(
(
VALUE /aws1/cl_cgpauthparamstype_w=>ts_authparameterstype_maprow(
value = new /aws1/cl_cgpauthparamstype_w( |string| )
key = |string|
)
)
)
it_clientmetadata = VALUE /aws1/cl_cgpclientmettype_w=>tt_clientmetadatatype(
(
VALUE /aws1/cl_cgpclientmettype_w=>ts_clientmetadatatype_maprow(
key = |string|
value = new /aws1/cl_cgpclientmettype_w( |string| )
)
)
)
iv_authflow = |string|
iv_clientid = |string|
iv_session = |string|
iv_userpoolid = |string|
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
lv_challengenametype = lo_result->get_challengename( ).
lv_sessiontype = lo_result->get_session( ).
LOOP AT lo_result->get_challengeparameters( ) into ls_row.
lv_key = ls_row-key.
lo_value = ls_row-value.
IF lo_value IS NOT INITIAL.
lv_stringtype = lo_value->get_value( ).
ENDIF.
ENDLOOP.
lo_authenticationresulttyp = lo_result->get_authenticationresult( ).
IF lo_authenticationresulttyp IS NOT INITIAL.
lv_tokenmodeltype = lo_authenticationresulttyp->get_accesstoken( ).
lv_integertype = lo_authenticationresulttyp->get_expiresin( ).
lv_stringtype = lo_authenticationresulttyp->get_tokentype( ).
lv_tokenmodeltype = lo_authenticationresulttyp->get_refreshtoken( ).
lv_tokenmodeltype = lo_authenticationresulttyp->get_idtoken( ).
lo_newdevicemetadatatype = lo_authenticationresulttyp->get_newdevicemetadata( ).
IF lo_newdevicemetadatatype IS NOT INITIAL.
lv_devicekeytype = lo_newdevicemetadatatype->get_devicekey( ).
lv_stringtype = lo_newdevicemetadatatype->get_devicegroupkey( ).
ENDIF.
ENDIF.
LOOP AT lo_result->get_availablechallenges( ) into lo_row_1.
lo_row_2 = lo_row_1.
IF lo_row_2 IS NOT INITIAL.
lv_challengenametype = lo_row_2->get_value( ).
ENDIF.
ENDLOOP.
ENDIF.