Auth0 Home Blog Docs

How to change the request body for passwordless sms

I am integrating the passwordless sms connection for my application with my own sms-gateway provider. However the request body accepted by my sms-gateway provider is different than what auth0 posts. Is there any way I can define the request body posted to my sms-gateway for passwordless sms.

For eg., the request body posted by auth0 is as follows:
{
“recipient”: “+1 399 999”,
“body”: “Your verification code is: 12345”,
“sender”: “+1 234 567”
}

Following is the sample Curl requests for my sms-gateway provider:
curl -X “POST” “https://rest.nexmo.com/sms/json
-d “from=AcmeInc”
-d “text=A text message sent using the Nexmo SMS API”
-d “to=$TO_NUMBER”
-d “api_key=$API_KEY”
-d “api_secret=$API_SECRET”

or

curl -X POST https://api.nexmo.com/v0.1/messages
-u “$NEXMO_API_KEY:$NEXMO_API_SECRET”
-H ‘Content-Type: application/json’
-H ‘Accept: application/json’
-d $’{
“from”: { “type”: “sms”, “number”: “’$FROM_NUMBER’” },
“to”: { “type”: “sms”, “number”: “’$TO_NUMBER’” },
“message”: {
“content”: {
“type”: “text”,
“text”: “This is an SMS sent from the Messages API”
}
}
}’

While we don’t offer full customization capabilities to talk to different SMS gateways, you can follow the instructions from Set Up Custom SMS Gateway for Passwordless Connections and point it to a custom-built endpoint (which you will have to provide) that should act as a translator, receiving Auth0’s requests, verifying their authenticity and then make the request to your SMS gateway.

1 Like