Twilio Integration plugin has a deep integration with the Backendless to enable the following capabilities:
- User registration with phone number confirmation;
- Login with a phone number – two factor authentication (2FA);
- Sending SMS/MMS API.
Twilio Integration plugin has a deep integration with the Backendless to enable the following capabilities:
This marketplace product enables phone-based authentication for the Backendless login process and also provides some useful APIs, such as sending out an SMS/MMS message. The plugin is deeply integrated into Backendless to provide a seamless experience requiring minimal changes. The standard user registration and login workflows are extended by the plugin to take advantage of its ability to send out SMS and thus provide the 2FA capability.
Once the Twilio plugin is installed, you can verify it by navigating to the Business Logic section of Backendless Console:
The plugin consists of an API service and several API Event handlers which enable deep integration into the user registration and login workflows. The API service has several operations which you can test and try directly from Backendless Console. See below for information about the API operations provided with the Twilio API service.
The functionality of the Twilio Integration Plugin relies on a phone number present for every user. The phone number must be stored in the Users
table. The name of the column where the phone number is stored is phoneNumber
, however, you can change the name using the Service Configuration window shown above. To access the window, select the Business Logic section of Backendless Console, select the Twilio service and click the gear icon as shown below:
In the Service Configuration window see the User Phone Number Field property.
As you will see in the APIs documented below, the phone number is present in every registration and login request. The Twilio Integration Plugin uses the phone number column to send out a code which is used to confirm user’s identity.
The API supported by the Twilio Integration Plugin can be used either via REST or using a Backendless SDK. To use the API with an SDK, generate the client-side library for the API as shown below:
In case a language you would like to use does not appear in the list, you can still use the plugin. The information below describes all available options.
Consider the following scenario: your application’s registration form includes a field for the user’s phone number. When a user creates an account, they provide a phone number that you would like to verify before their account is enabled. They can then log in after the registration process is complete.
The process of user registration with phone number confirmation consists of the following steps:
"transactionId"
.email
or the property/column used as identity by your application.password
– user’s passwordtransactionId
– this is the value from step 1.transactionCode
– this is the code sent to the user’s phone in step 2.phoneNumber
– this is the same number used in step 1. This is required as a security measure.It is possible to configure your application to use the phoneNumber column as identity. In this case, the second registration API call will include only four properties (phoneNumber
, password
, transactioniId
and transactionCode
).
First registration request:
Request Body:
Response:
Second registration request:
Request Body:
Response:
Second registration request:
Second registration request:
Second registration request:
Second registration request:
Second registration request:
Second registration request:
Consider a scenario where an application login form requires user’s phone number and their password. The user enters their phone number and the password. If the password is correct, the user receives a code via SMS and enters the code into the application to complete the login. This scenario is supported by the API documented below.
The process consists of the following steps, which include two service API calls:
transactionId
value.Request Body is just a string value of the phone number:
Response Body
Request Body:
Response Body:
The user-token property value is important, as it identifies the session of the user with Backendless. The value must be passed to the server as an HTTP header with all subsequent API calls.
With Android SDK:
Request to confirm code:
With Android Client SDK – downloaded from Backendless Console per the instructions above:
With SDK for Android:
Request to confirm the code:
Request to confirm code:
Request to confirm the code:
Request to confirm code:
Request to confirm code:
Consider a scenario where an application login form requires user’s phone number and their password. The user enters their phone number and the password. If the password is correct, the user receives a code via SMS and enters the code into the application to complete the login. This scenario is supported by the API documented below. The process consists of the following steps which include two service API calls:
transactionId
value.transactionId
and the code from step 2 to the Twilio Integration Plugin service.Request Body:
Response Body
Request Body:
Response Body:
The user-token
property value is important, as it identifies the session of the user with Backendless. The value must be passed to the server as an HTTP header with all subsequent API calls.
With Android SDK:
Request to confirm the code:
With Android Client SDK:
With SDK for Android:
Request to confirm the code:
Request to confirm the code:
Request to confirm the code:
Request to confirm code:
Request to confirm code:
The API below provides a way to send SMS/MMS messages using Twilio Integration Plugin via your Twilio account.
Request Body:
The mediaUrl
is an optional parameter. If provided, it must contain an HTTPS URL for an image to be delivered in an MMS message.Response Body:Same response as documented by Twilio – https://www.twilio.com/docs/sms/send-messages
With SDK for Android: