A Flutter plugin for integrating Authyo β a powerful multi-channel MFA service supporting WhatsApp, SMS, Email, and Call for OTP verification.
This plugin enables developers to implement OTP-based authentication for both legacy systems and modern, passwordless solutions with minimal configuration.
- π± Multi-channel support (WhatsApp, SMS, Email, Call)
- π§© Plug-and-play OTP UI (or bring your own)
- π§Ύ Works for both new and legacy systems
- π Configurable channel priority (no redeploy needed)
- π JWT-based login for new systems
- π§ REST API Support
- π Transparent billing & usage dashboard
- π Free trial for all new accounts
- π€ Affiliate support built-in
Add the dependency in your pubspec.yaml:
dependencies:
authyo_flutter: <latest_version>Run:
flutter pub getAdd to your pubspec.yaml:
dependencies:
authyo_plugin: ^1.0.0 //Latest versions may vary
Import in your Dart code:
import 'package:authyo_plugin/authyo_plugin.dart';
Important:
You must initializeAuthyoServicewith yourclientIdandclientSecretbefore making any requests.
//Get AuthyoService Instance
final AuthyoService authyoService = AuthyoService.instance;
//Initialize AuthyoService using your Authyo credentials
authyoService.init(clientId: "YOUR_CLIENT_ID", clientSecret: "YOUR_CLIENT_SECRET");
// Call sendOtp function using AuthyoService
AuthyoResult otpResult = await authyoService.sendOtp(
ctx: context,
to: β+1234567890β, // or βuser@email.comβ
otpLength: 6, // optional, defaults to 6
expiry: 180, // optional, in seconds
authWay: AuthwayEnum.SMS, // optional, can be SMS, Whatsapp, Email, Voice
onVerificationComplete: (authyoResult) {
// This callback is optional and only necessary if plugin's default OTP verification dialog is used.
// If custom UI for OTP verification is used, you can omit this callback.
// Check for result.
if (authyoResult.result?.error == null) {
// Verification successful.
}
});
bool success = otpResult.result?.data?.results?.firstWhere((element) => element.success == true, orElse: () => Results(success: false)).success;
if (success == true) {
print("β
OTP Sent: ${otpResult.result?.message}");
} else {
print("β Error: ${otpResult.error?.message}");
}
// Call verifyOtp function using AuthyoService instance
AuthyoResult otpResult = await AuthyoService.instance.verifyOtp(maskId: "Mask ID",otp: "Received OTP");
if(otpResult.result!=null){
print("Success: ${otpResult.result?.message}");
}
else{
print("Error: ${otpResult.error?.message}");
}
init({required String clientId, required String clientSecret, Duration? connectTimeout, Duration? receiveTimeout, bool? showVerificationDialog})
Future<AuthyoResult> sendOtp({
required String to,
int otpLength = 6,
int? expiry,
AuthwayEnum? authWay,
void Function(AuthyoResult authyoResult)? onVerificationComplete
});
- to: Phone number or email (required)
- otpLength: Length of OTP (optional, defaults to 6)
- expiry: OTP expiry in seconds (optional)
- authWay: Channel to send OTP (optional, defaults to dashboard preference)
- onVerificationComplete: Optional callback function which provide if authentication is successful or not. Only required when plugin's default OTP verification dialog is being used.
Returns: AuthyoResult
Future<AuthyoResult> verifyOtp({required String maskId, required String otp})
- maskId: Received from
sendOtpresponse (required) - otp: The OTP entered by the user (required)
Returns: `AuthyoResult
A wrapper for API responses.
class AuthyoResult {
final AuthyoResponseModel? result;
final AuthyoError? error;
AuthyoResult.success(this.result) : error = null;
AuthyoResult.failure(this.error) : result = null;
}
For sendOtp:
{
"success": true,
"message": "submited successfully",
"data": {
"isTried": 1,
"isSent": 1,
"results": [
{ "success": true,
"message": "message submitted successfully",
"to": "919898******",
"authtype": "WHATSAPP",
"maskId": "36eeb3a16fAaAab49b48de0d729b9a35",
"createdTime": 1747312374,
"expiretime": 1747312434
}
]
}
}
For verifyOtp:
{
"success": true,
"message": "OTP Verified Successfully",
"status": "verified",
"data": {
"tokenType": "Bearer",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJGYTh6bE92N2FMUTdRcEl6enVkQnh3R0VxMVhTZUFCalRvcXdjcE0zM2w4PSIsImlzcyI6Imh0dHBzOi8vYXV0aHlvLmlvIiwiYXVkIjoiYWVhNWRhYzBlMjNDhiZmJjYzhjMTdmMDM2ZDlhZjgiLCJpYXQiOiIxNzUxOTA0MzkyIiwiZXhwIjoiMTc1MTkwNDY5MiIsInVzZXJJZCI6IkFZLUZhOHpsT3Y3YUxRN1FwSXp6dWRCeHdHRXExWFNlQUJqVG9xd2NwTTMzbDg9IiwicGhvbmUiOiI5MTc0MDUwODkwOTkifQ.6U3gFxTqSTuHNtsA77pRfvo8i9f0wfgvqbWb088v8Lg",
"expiresIn": 300,
"user": {
"phone": "9174050*****",
"userId": "AY-Fa8zlOv7aLQ7QpIzzudBGEq1XSeABjToqwcpM33l8="
}
}
}
All errors are subclasses of AuthyoError, including:
BadRequestError(400)UnauthorizedError(401)ForbiddenError(403)NotFoundError(404)TooManyRequestsError(429)InternalServerError(500)ServiceUnavailableError(503)NetworkErrorTimeoutErrorUnknownApiError
Read the full documentation for implementation steps, API tokens, dashboard configuration, and more.
Sign up at authyo.io and get free credits to test MFA in your app.
Promote Authyo and earn revenue. Details on your Authyo Dashboard.
For issues, feature requests, or contributions, file a GitHub issue or contact support via authyo.io.