Step 1: Add SDK Dependency
Add the OTPLESS SDK to your project by including the following script in the<body>
section of your HTML document:
index.html
Replace
YOUR_APP_ID
with your actual App
ID provided in
your OTPLESS dashboard.Step 2: Initialize SDK and Handle Callback
Initialize the SDK and set up a callback function to handle authentication:- Install OTPLESS SDK Dependency
- Import the following classes and declare variables:
login_page.dart
- Add a method to receive callbacks from OTPless:
login_page.dart
- Add this code to your
initState()
method in your SignIn/SignUp page:
login.dart
Step 3: Initiate Authentication
Initiate the authentication process based on the user’s selected method by using theinitiate
method of the SDK.
- Phone Auth
- Email Auth
- OAUTH
(Optional): Verify OTP
To verify the OTP entered by the user, use theverify
method with the necessary parameters.- Request
- Response
- Error Codes
Attribute | Mandatory | Description |
---|---|---|
channel | Yes | The authentication method selected by the user. |
phone | Conditional | User’s phone number (required if channel is PHONE). |
countryCode | Conditional | Country code of the phone number (required if channel is PHONE). |
email | Conditional | User’s email (required if channel is EMAIL). |
channelType | Conditional | Type of social login initiated (required if channel is OAUTH). |
🏁 Checkpoint
To ensure a smooth integration process:- Deploy your app/website with the included OTPLESS SDK.
- Conduct tests to verify the sign-in flow functions correctly.
- Ensure that after a successful sign-in, the user is redirected back to your app/website and their information is correctly logged in the console.
User Information Response Structure
The structure of the user information returned upon successful sign-in is as follows:You can check out a complete sample response
here.
Next Steps
Validate ID Token
Learn how to securely `validate ID token` returned by OTPLESS flutter SDK to ensure the authenticity of sign-in events from your backend server.
Validate Token (Opaque)
Learn how to securely `validate token` returned by OTPLESS flutter SDK to ensure the authenticity of sign-in events from your backend server.