Prerequisites
- Make sure you have followed the SDK Setup Guide before starting with this document.
- Ensure you have admin access to the OTPless Account.
- Log in to the OTPless dashboard with your registered email ID.
- Go to Configure Channel.
- Enable the phone or email channel based on your requirement.
- When you enable the channel, you will see the option to configure the auth method and delivery channel.
- Choose Magic Link as the auth method.
Important: Don’t forget to save and publish the configuration.
Step 1: Send Magic Link
Choose your identity type to verify:
To initiate an Magic Link for phone number verification, set the phone number and country code for the Magic Link request.Requestlet headlessRequest = {};
headlessRequest = {
countryCode,
phone
}
await manager.startHeadless(headlessRequest);
Response{
"statusCode": 200,
"success": true,
"response": {
"channel": "PHONE",
"deliveryChannel": "WHATSAPP",
"authType": "MAGICLINK",
"requestId": "xxxxxxxxxxxxxxxx"
}
}
To initiate a Magic Link for email verification, set the email address for the Magic Link request.Requestlet headlessRequest = {};
headlessRequest = {
email,
};
await manager.startHeadless(headlessRequest);
Response{
"statusCode": 200,
"success": true,
"response": {
"channel": "EMAIL",
"deliveryChannel": "EMAIL",
"authType": "MAGICLINK",
"requestId": "xxxxxxxxxxxxxxxx"
}
}
Step 2: Get Auth Token
Awesome! You’ve completed the client-side integration. Now, after the Magic Link is verified, you’ll get a callback with the ONETAP response containing the token. You’ll need to parse the token from the response JSON.
Sample Callback JSON
{
"responseType": "ONETAP",
"statusCode": 200,
"response": {
"status": "SUCCESS",
"token": "unique_token_here",
"userId": "unique_user_id_here",
"timestamp": "ISO_timestamp_here",
"identities": [
{
"identityType": "MOBILE",
"identityValue": "919899038845",
"channel": "MAGIC_LINK",
"methods": [
"WHATSAPP"
],
"verified": true,
"verifiedAt": "2024-08-05T14:01:31Z"
}
],
"idToken": "jwt_token",
"network": {
"ip": "127.0.0.1",
"timezone": "Asia/Kolkata",
"ipLocation": {}
},
"deviceInfo":{},
"sessionInfo":{},
"firebaseInfo":{}
}
}
You can view a complete sample response here
🏁 Check Point : Verify Auth Token
Once you have retrieved the token, send it to your backend and call the verify token API.
Verify Token API →