Comment on page
Token Management
How the Flutter SDK manages your user's tokens
The Passage Flutter SDK manages your user's auth tokens for you. Anytime your user successfully registers or logs in, their auth token and refresh token (if applicable) are stored securely on their device or browser.
You can access the current user's auth token this way:
final passage = PassageFlutter();
String? authToken = await passage.getAuthToken();
If the user has NOT authenticated or has been signed out,
passage.getAuthToken()
will return null
.
If you've setup refresh tokens in your app (strongly recommended), you can call
passage.refreshAuthToken()
to get a new auth token. This method will store the new auth token and return it.String newAuthToken = passage.refreshAuthToken();
You may want to check if your auth token is valid before using it to make sure you don't need to refresh the auth token.
// Retrieve auth token
String? authToken = await passage.getAuthToken();
// Check if the auth token is valid
bool isValid = await passage.isAuthTokenValid(authToken!);
When you call
passage.signout()
, the user's tokens are removed from the device.await passage.signOut();
Your user's auth token and refresh token are both stored on device using Apple's Keychain API. When you sign out your user, the refresh token is revoked on the server and both tokens are removed from the device.
Your user's auth token and refresh token are both stored on device using Android's own Encrypted Shared Preferences library. When you sign out your user, the refresh token is revoked on the server and both tokens are removed from the device.
Passage Flutter will store, lookup and clear auth tokens in localStorage and in a cookie using a consistent key value.
Last modified 3mo ago