JustPassMe is an awesome authentication library that lets you register and authenticate users using passkeys. Passkeys are secure and convenient ways to log in without passwords. No more forgetting passwords or resetting them every time! ๐
To use JustPassMe in your flutter app, you need to :-
In Dashboard, create an organization, and add the following details:
Bind your verification assets into your Android app's build.gradle file in /android/build.gradle
:
android {
defaultConfig {
resValue("string", "host", "https://<YOUR_ORGANIZATION_ID>.accounts.justpass.me")
resValue("string", "asset_statements", """
[{
"include": "https://<YOUR_ORGANIZATION_ID>.accounts.justpass.me/.well-known/assetlinks.json"
}]
""")
}
}
Add the following meta-data to your <application>
tag in AndroidManifest.xml
file in /android/src/main/AndroidManifest.xml
:
<manifest>
<application>
<meta-data
android:name="asset_statements"
android:resource="@string/asset_statements" />
</application>
</manifest>
Build your project to make everything take effect, it should build successfully.
(Optionl) You can validate your assetlinks.json
is working by opening this link https://<YOUR_ORGANIZATION_ID>.accounts.justpass.me/.well-known/assetlinks.json
in your browser and make sure your android package and SHA-1 fingerprint are listed in the file.
Start your backend integration, checkout our Backend Documentation
By the end of this step you should have your passkey registration
and login
APIs ready to use in your app.
To install JustPassMe in your Flutter app, you just need to add the following dependency to your app's pubspec.yaml
file:
Run this command:
With Dart:
$ dart pub add justpassme_flutter
With Flutter:
$ flutter pub add justpassme_flutter
This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):
dependencies:
justpassme_flutter: ^0.0.1+1
Note : This is a beta version of the library and the API design may change before the stable release. Stay tuned for updates! ๐ฅ
To use JustPassMe in your app, you need to do the following:
import 'package:justpassme_flutter/justpassme_flutter.dart';
final justPassMeClient = JustPassMe();
2. After finishing the backend integration, you will need to know the API endpoints for both registration and login, Incase of using Firebase as your backend, checkout our [Firebase Documentation](/pages/docs/backend/firebase-extension.md) your endpoints will be as follows:
- Backend
```dart
final BASE_URL = "https://<YOUR_backend_DOMAIN>";
- Firebase
```dart
final BASE_URL = "https://<YOUR_FIREBASE_PROJECT_ID>.cloudfunctions.net/ext-justpass-me-oidc/";
```
To create a passkey for your logged in user, you need to do the following:
BASE_URL
:
final registrationUrl = "${BASE_URL}/<YourRegistrationEndpoint>";
final registrationUrl = "${BASE_URL}/register";
final headers = {"Authorization" : "Bearer $token"};
final result = await justPassMeClient.register(registrationUrl , headers);
To log in a user that has a passkey for your app, you need to do the following:
final loginUrl = "${BASE_URL}/<YourLoginEndpoint>";
final loginUrl = "${BASE_URL}/authenticate";
val extraHeaders = {"Header-Key": "Header-Value"};
3. Call the auth method on the `justPassMe` instance and pass the login URL, the extra headers map (if any), and a callback function as parameters:
```dart
final result = await justPassMeClient.login(loginUrl, headers);
The callback function receives a map object that represents your login creditials
If you are using Fireabse make sure to login the user in fireabse with the result custom token
String? token = result['token'] as String?;
if (token != null) {
await FirebaseAuth.instance.signInWithCustomToken(token);
}
Thatโs it! You have successfully integrated JustPassMe in your app and made it easier for your users.