This page is an extension of the regular Authentication API: Start a new authentication (POST). However, in this case, usage of SMS for authentication requires special considerations, which are the 2 additional fields smsMessage
and smsSender
.
Authenticate using SMS, without payload (POST)
This section focuses on the scenarios where the authenticating device is an SMS device.
The authenticating device is an SMS device in one of the following cases:
- The authentication request contains the device ID which is known to be an SMS device.
- The authentication request does not contain the device ID, and it is possible that the authenticating device will be an SMS device.
The following examples deal with scenarios in which an authentication request does not contain a mobile application payload.
Relative Path
/accounts/{accountId}/applications/{applicationId}/users/{username}/authentications
Additional fields in the authentication request body structure
{
"smsMessage": "<sms authentication message>",
"smsSender": "<the sms sender>"
}
Request parameters
Parameter | Description |
---|---|
smsMessage |
The SMS message.
|
smsSender |
The sender ID of the SMS message.
If the sender ID is specified:
|
Authentication using the additional SMS fields
SMS authentication request body
Some countries require the SMS sender ID (smsSender
) to be empty, as shown in this example:
curl -X POST \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: PINGID-HMAC=<JWT>' \
-d '{ \
"smsMessage": "Your authentication is code: ${otp}", \
"smsSender": "" \
}' 'https://sdk.pingid.com/pingid/v1/accounts/bb09a7a1-b359-418c-9c66-d8b91d83fda4/applications/3f02bbd2-1291-41ae-9663-3a2b75956d6a/users/user1/authentications'
SMS authentication response
"id": "webs_4259429a-8fb2-438c-8897-c205f188f4a3",
"deviceId": "6086deb9-def7-bfc2-6086-deb9def7bfc2",
"status": "OTP",
"requiredLevel": "PUSH",
"level": "NONE",
"payload": ""
Finalizing SMS authentication
When the authenticating device is an SMS device, the authentication must be finalized.
The PUT method using the otp
parameter with the OTP value returned by the user finalizes authentication.
The session becomes invalid after successful authentication has completed. If there is an attempt to reuse the same OTP in the same user authentication session, it will be rejected.
Request body structure
Use the following request body structure to finalize authentication:
{
"otp": "<the OTP from the user>",
}
SMS authentication finalization request body example
curl -X PUT \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: PINGID-HMAC=<JWT>' \
-d '{ \
"otp": "363451" \
}' 'https:// sdk.pingid.com/pingid/v1/accounts/bb09a7a1-b359-418c-9c66-d8b91d83fda4/applications/3f02bbd2-1291-41ae-9663-3a2b75956d6a/users/user1/authentications/webs_4259429a-8fb2-438c-8897-c205f188f4a3/otp'
SMS authentication finalization response example
{
"id": "webs_4259429a-8fb2-438c-8897-c205f188f4a3",
"status": "APPROVED",
"deviceId": "6086deb9-def7-bfc2-6086-deb9def7bfc2",
"requiredLevel": "PUSH",
"level": "OTP",
"payload": ""
}
SMS authentication with SDK payload
Any authentication request which originates from a mobile application that is integrated with PingID SDK must always contain the SDK payload. If an application with SDK integration on an unpaired mobile device issues an authentication request to an active user who has at least one paired device, the user’s primary or selected device must approve authentication to the unpaired device.
When the approving device is an SMS device, the smsMessage
parameter in the authentication request may also contain the accessing device’s name and device type.
SMS authentication structure example, when the request contains SDK payload
{
"payload": "<payload from the mobile application>",
"smsMessage": "New device access: ${device_name} ${device_type}. If you approve, use the code: ${otp}",
"smsSender": "<the sms sender ID>"
}
Parameter | Description |
---|---|
payload | The payload returned from the mobile application with SDK integration. |
smsMessage |
The SMS message.
|
smsSender |
The sender ID of the SMS message. This parameter is optional, and is the same as when authenticating without a payload. If the sender ID is specified:
If the sender field is empty, the SMS sender will be an arbitrary PingID phone number, except for India. If the SMS recipient is located in India, the sender will appear as "PingID", which is the required registered sender ID in India. |