rauth-flutter
A lightweight, cross-platform Flutter/Dart library for adding reverse authentication via WhatsApp to your mobile or web apps.
This library allows you to generate a reverse authentication token in your Flutter application. The user verifies their identity via WhatsApp, and your app can send the session token to your backend for verification.
๐ You must install
rauth-provideron your Node.js backend to verify tokens issued byrauth-flutter.
โ Features
๐ฑ Client-Side Reverse Auth โ Generate session tokens from your Flutter app without traditional OTP flows.
๐ Cross-Platform โ Works on Android, iOS, and Web (Flutter web).
๐ฌ WhatsApp-Based Verification โ Lets users verify themselves via WhatsApp without requiring any SMS.
๐งฉ Plug-and-Play SDK โ Just call RauthClient.init() with appId and phone number, and you're done.
๐ Secure Token Generation โ Uses HMAC signatures to prevent tampering or spoofing.
๐ผ QR + Link Options โ Automatically returns a WhatsApp Web link and QR image for alternate login devices.
๐งช Easy Testing & Debugging โ Returns session token, WhatsApp link, and QR image for easy integration.
๐ Production Ready โ Designed to integrate securely with your backend for session verification via rauth-provider.
๐ง Install
Add to your pubspec.yaml:
dependencies:
rauth_flutter:
path: ../rauth-flutter # or use your published version
Then run:
flutter pub get
๐ฆ Prerequisites
- Create a free account at https://rauth.io
- Generate your
appIdandappSecretfrom the dashboard. - Use this library in your Flutter app.
- Use
rauth-provideron your backend to verify tokens.
๐ก Usage
Basic Example
import 'package:rauth_flutter/rauth_flutter.dart';
final client = RauthClient(appId: 'your-app-id', appSecret: 'your-app-secret');
final session = await client.init(phone: '+917000000000');
print('Session Token: \\${session.sessionToken}');
print('WhatsApp Link: \\${session.waLink}');
print('QR Image (base64): \\${session.qrImageLink}');
With UI (see demo app)
- Input phone number
- Call
RauthClient.init(phone: ...) - Show QR code and WhatsApp link to user
๐ Backend Verification Example
After the user verifies via WhatsApp, send the session token to your backend:
POST /login
{
"phone": "+917000000000",
"token": "dfsdf-fdsdfsdfsd-dsfsdfg84-fsadfgsdag"
}
Your backend (using rauth-provider) should validate the token and return a JWT or session data if verified.
๐ License
MIT