Set up SMS verification with Aliyun Short Message Service
The official Logto connector for Aliyun short message service.
In this guide, we assume you have basic knowledge of Logto Connectors. If you don't, check out the Configure connectors guide to get started.
Get started
Aliyun is a primary cloud service provider in Asia, offering many cloud services, including SMS (short message service). Aliyun SMS Connector is a plugin provided by the Logto team to call the Aliyun SMS service, with the help of which Logto end-users can register and sign in to their Logto account via SMS verification code.
Set up a short message service in Aliyun SMS Console
Create an Aliyun account
Go to the Aliyun website and register your Aliyun account if you don't have one.
Enable and Configure Aliyun Short Message Service
- Sign-in with your Aliyun account at the Aliyun website and go to the SMS service console page.
- Click the "Open for free" (免费开通) button on the top left of the SMS service page and begin the configuration process.
- Read and agree to the "SMS service activation Agreement" (短信服务开通条款) and click "Subscribe to a service" (开通服务) to move on.
- You are now on the SMS service console page, go to either "Mainland China" (国内消息) or "Outside Mainland China" (国际/港澳台消息) button on the sidebar per your use case.
- Add signature and template following the guidelines, and provide the materials or information required for review.
- Remember to select "Verification Code Message" (验证码) as "Scenario" (适用场景) when filling out the signature application and also "Verification Code Message" (验证码) for "Type" (模板类型) when applying for a template review because we are using these signatures and templates to send verification code. Currently, we do not support sending SMS messages other than verification-code-related text messages.
- Also, use
{{code}}
as a placeholder where you want to place your digital verification code in template contents.
- After submitting your SMS signature and template application, you need to wait for it to take effect. At this point, we can go back to the SMS service console page and send a test SMS. If your signatures and templates are ready for use, you can try them directly; if they are not taking effect yet, Aliyun also provides test templates.
- You may need to recharge a small amount of money before sending test messages.
- You may also be asked to bind a test phone number before sending test messages. For more details, go to "Quick Start" (快速学习) tab from the sidebar of the SMS service console page.
Compose the connector JSON
- From the SMS service console page, hover on your avatar in the top right corner and go to "AccessKey Management" (AccessKey 管理), and click "Create AccessKey" (创建 AccessKey). You will get an "AccessKey ID" and "AccessKey Secret" pair after finishing security verification. Please keep them properly.
- Go to the "Mainland China" (国内消息) or "Outside Mainland China" (国际/港澳台消息) tab you just visited, you can find "Signature" (签名名称) and "Template Code" (模板 CODE) easily.
- If you want to use the test-only signature and template, go to the "Quick Start" (快速学习) tab instead, and you will find them below "Signature & Templates (For Test Only)".
- Fill out the Aliyun SMS Connector settings:
- Fill out the
accessKeyId
andaccessKeySecret
fields with access key pairs you've got from step 1. - Fill out the
signName
field with "Signature" (签名名称) which is mentioned in step 2. All templates will share this signature name. - You can add multiple SMS connector templates for different cases. Here is an example of adding a single template:
- Fill the
templateCode
field, which is how you can control SMS context, with "Template Code" (模板 CODE) from step 2. - Fill out
usageType
field with eitherRegister
,SignIn
,ForgotPassword
orGeneric
for different use cases. (usageType
is a Logto property to identify the proper use case.) In order to enable full user flows, templates with usageTypeRegister
,SignIn
,ForgotPassword
andGeneric
are required.
- Fill the
- Fill out the
Test Aliyun SMS connector
You can type in a phone number and click on "Send" to see whether the settings can work before "Save and Done".
That's it. Don't forget to Enable connector in sign-in experience.
Config types
Name | Type |
---|---|
accessKeyId | string |
accessKeySecret | string |
signName | string |
templates | Template[] |
Template Properties | Type | Enum values |
---|---|---|
templateCode | string | N/A |
usageType | enum string | 'Register' | 'SignIn' | 'ForgotPassword' | 'Generic' |