flutter_secure_token_manager

Last updated:

0 purchases

flutter_secure_token_manager Image
flutter_secure_token_manager Images
Add to Cart

Description:

flutter secure token manager

Flutter Secure Token Manager #
What it does #

Secure Storage: Safely stores access token and refresh token.
Efficient Token Refresh: Efficiently renews access tokens upon expiration, ensuring a single
refresh request even when multiple requests detect token expiry simultaneously.
Token Expiry Check: Provides a mechanism to check if tokens have expired (only for JWT).

Implementation Steps #


Add Package: Include the package in your Flutter project.
dependencies:
flutter_secure_token_manager: ^latest_version
copied to clipboard


Set Tokens After Login:
Use FlutterSecureTokenManager().setToken(Token(accessToken, refreshToken)) whenever there are
changes to tokens.


Implement Token Expiry Check: If your tokens are not JWT, set the expiry check logic (usually
done once at the beginning).
FlutterSecureTokenManager().isTokenExpired = (accessToken) async {
// Your logic here
// return true or flase; //
};
copied to clipboard


Token Refresh Logic: Implement the logic for refreshing the token when it expires.
FlutterSecureTokenManager().onTokenExpired = (refreshToken) async {
// Your logic here to get new access token with refreshToken;
// return newToken;
};
copied to clipboard


Access Token Retrieval: Use FlutterSecureTokenManager().getAccessToken() wherever you need
the access token. The package will handle the refresh automatically.
headers: {
"Authorization": "Bearer ${await FlutterSecureTokenManager().getAccessToken()}"
}
copied to clipboard


Note: Ensure these steps are appropriately integrated into your app flow, especially during the
login process and before making authenticated requests.
🚀 Actively seeking feedback and suggestions for further enhancements to make this plugin even more
valuable! Share your thoughts to contribute to its improvement. Feel free to reach out if you have
any questions or encounter issues. Happy coding! 🙌

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.