checkToken(serviceId, toopt, code, paramsopt) → (nullable) {object}
Checks the user-provided verification token (code) matches the one sent.
Parameters:
Name |
Type |
Attributes |
Description |
serviceId |
string |
|
Service SID of the verification service to use.
|
to |
string |
<optional> |
Recipient phone number or email address. Phone numbers must be in E.164 format. Can be omitted if a VerificationSid parameter is provided.
|
code |
string |
|
The verification token (code) to check.
|
params |
object |
<optional> |
Optional parameters to include.
|
-
See:
-
Throws:
-
HttpNotFoundError
-
Thrown when the verification has expired or has already been completed.
Returns:
object
Details of the verification. Returns null
if one or more parameters are invalid.
Examples:
// Check the user-provided verification code
const status = connectors.verjio.twilio.verify.checkToken(
fields.service_sid.value,
fields.phone_number.value,
fields.code.value
)
// If the code was correct, the status will be `approved`
if (status === connectors.verjio.twilio.verify.status.APPROVED) {
form.gotoPage('SignedIn');
}
// Send a code to the user's phone
const verification = connectors.verjio.twilio.verify.sendToken(
fields.service_sid.value,
fields.phone_number.value
);
// Wait for user to provide code
// Check the code using the verification SID
// rather than the user's details
connectors.verjio.twilio.verify.checkToken(
fields.service_sid.value,
null,
fields.code.value,
{
VerificationSid: verification.sid
}
);
createService(name, codeLengthopt, paramsopt) → (nullable) {object}
Create a new verification service. All verification requests must be made using a verification service.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
name |
string |
|
|
Friendly name of the verification service. This may be visible to users. The name must be 30 characters or less and can only contain letters, numbers, spaces, dashes and underscores.
|
codeLength |
integer |
<optional> |
4 |
Length of the verification codes to send. Values between 4 and 10 (inclusive) are accepted. Defaults to 4 .
|
params |
object |
<optional> |
|
Optional parameters to include.
|
-
See:
-
Returns:
object
Details of the new verification service. Returns null
if one or more parameters are invalid.
Example:
// Create a new verification service
// Verification codes will be 5 characters long.
const service = connectors.verjio.twilio.verify.createService(
'Sandy\'s Ice Cream',
5
);
// Save the SID
if (service) {
fields.service_sid.value = service.sid;
}
sendToken(serviceId, to, channelopt, paramsopt) → (nullable) {object}
Send a verification token (code) to the specified recipient. The token can be sent using several channels
.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
serviceId |
string |
|
|
Service SID of the verification service to use.
|
to |
string |
|
|
Recipient phone number or email address. Phone numbers must be in E.164 format
|
channel |
TwilioVerify.Channel |
<optional> |
sms |
Length of the verification codes to send. Values between 4 and 10 (inclusive) are accepted. Defaults to 4 .
|
params |
object |
<optional> |
|
Optional parameters to include.
|
-
See:
-
Returns:
object
Details of the verification. Returns null
if one or more parameters are invalid.
Example:
// Send a verification code
connectors.verjio.twilio.verify.sendToken(
fields.service_sid.value,
fields.phone_number.value
);