After importing the fingerprint_dart_auth_sdk into your Flutter project, as mentioned in the previous step, it's time to initialize Fingerprint using the SDK.
There are two methods you can use to achieve this:
Using environment variables
Using service account methods
Using Environment Variables
To use environment variables to initialize Fingerprint, first obtain your project ID and API key.
Your project ID can be found in the environments tab of your "Project settings" page via the link:
import 'package:fingerprint_dart_auth_sdk/fingerprint_dart_auth_sdk.dart';voidmain() async {//Pass the enviroment variables into the function below, I.E API key and project IDFingerprintApp.initializeAppWithEnvironmentVariables( apiKey:FINGERPRINT_API_KEY, projectId:FINGERPRINT_PROJECT_ID, );// Get Firebase auth instance for this projectFingerprintApp.instance.getAuth();// Example: Sign in with email and passwordtry {final user =awaitFingerprintApp.fingerprintAuth?.createUserWithEmailAndPassword('[email protected]','password');finalawait userCredential =awaitFingerprintApp.fingerprintAuth?.signInWithEmailAndPassword('[email protected]','password');print('Signed in as ${userCredential?.user.email}'); } catch (e) {print('Sign-in error: $e'); } }
Use the FingerprintApp.initializeAppWithEnvironmentVariables() method to initialize Fingerprint passing in the environment variables.
Try signing in a user with the FingerprintApp.fingerprintAuth?.signInWithEmailAndPassword() authentication method, passing in required arguments. If login is successful, a return user's credential userCredential is returned.
Using the environment variables to initialize Fingerprint currently works on backend and frontend (all platforms).
Initializing Fingerprint using the Fingerprint Dart Auth SDK with the FingerprintApp.initializeAppWithEnvironmentVariables() method allows for user creation and management on both the client and server side.
Optional: Use Fingerprint Web SDK for frontend, OR use this SDK on backend for user operations.
Environment Variables can be used for:
✅ Backend user creation
✅ Password resets
✅ Authentication
❌ Token verification
Using Service Account Methods
To obtain the service account keys follow the steps below:
Login into your Fingerprint dashboard.
Click on the Fingerprint project you want to get the service keys.
Click on the gear icon in "Project Overview" on the left sidebar
Click on "Project settings".
Select the "Service account" tab on the "Project settings" page.
Click the "Generate new private key" button to download your serviceAccountKey.json file.
Save the serviceAccountKey.json file with your project directory.
Note: Keep your serviceAccountKey.json file private and not pushed to public repositories.