Passwordless and OTP-less Authentication for your website and app. It helps you to authenticate user via their email or phone number.
To get started, you can create a free account at SAWO to get your API keys.
A step by step series of examples that tell you how to get a development env running. These instructions will let you render the form in your specified container, and allow you to attach successful login callback for futher actions.
dependencies:
sawo: ^0.1.3
flutter pub get
import 'package:sawo/sawo.dart';
In [project]/android/app/build.gradle set minSdkVersion to >= 19
In [project]/android/app/src/main/AndroidManifest.xml add this line
<uses-permission android:name="android.permission.INTERNET"/>
Sawo sawo = new Sawo(
apiKey: <YOUR-API-KEY>,
secretKey: <YOUR-Secret-Key>,
);
NOTE: It is always recommended to store your apiKey and secretKey in a .env file. Otherwise, create a separate .dart file and add it to the .gitignore. Just make sure that you are not exposing the keys publicly and also add them to the .gitignore before pushing the project to a public repo.
// sawo object for Android/ios
Sawo sawo = Sawo(
apiKey: "",
secretKey: "",
);
// user payload
String user = "";
void payloadCallback(context, payload) {
if (payload == null || (payload is String && payload.isEmpty)) {
payload = "Login Failed :(";
}
setState(() {
user = payload;
});
}
@override
Widget build(BuildContext context) {
return Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("UserData :- $user"),
ElevatedButton(
onPressed: () {
sawo.signIn(
context: context,
identifierType: 'email',
callback: payloadCallback,
);
},
child: const Text('Email Login'),
),
ElevatedButton(
onPressed: () {
sawo.signIn(
context: context,
identifierType: 'phone_number_sms',
callback: payloadCallback,
);
},
child: const Text('Phone Login'),
),
],
),
),
);
}
When the user is successfully verified, the callback method will get invoked with the payload containing the userID and other information. It will return empty payload for unsuccessful verification.
This project is licensed under the BSD-3-Clause License