Comment on page
Token Management
How the React Native SDK manages your user's tokens
The Passage React Native 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.
You can access the current user's auth token this way:
const 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.const 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
const authToken = await passage.getAuthToken();
// Check if the auth token is valid
const 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 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.
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.
Last modified 2mo ago