flutter_secure_auth 0.1.5 copy "flutter_secure_auth: ^0.1.5" to clipboard
flutter_secure_auth: ^0.1.5 copied to clipboard

A secure, lightweight authentication package for Flutter (REST + OAuth2 PKCE + token refresh) with secure local storage.

flutter_secure_auth πŸ”’ #

A secure, lightweight, and null-safe authentication package for Flutter.
It supports:

  • πŸ” OAuth2 PKCE Authorization Code flow
  • πŸ” Access/Refresh token handling
  • 🧠 Auto token refresh
  • πŸ’Ύ Secure token storage (Keychain / Keystore)
  • ⚑ Easy REST integration

Designed for developers who want security + simplicity when integrating login systems in Flutter apps.


πŸš€ Installation #

Add this to your pubspec.yaml:

dependencies:
  flutter_secure_auth: ^0.1.0

🧩 Usage
#Initialize
final authService = AuthService(
  tokenEndpoint: Uri.parse('https://api.example.com/oauth/token'),
  revokeEndpoint: Uri.parse('https://api.example.com/oauth/revoke'),
);

#πŸ”Έ Sign in with username/password
final tokens = await authService.signInWithPassword(
  endpoint: Uri.parse('https://api.example.com/auth/login'),
  username: 'user@example.com',
  password: 'securePassword',
);

#πŸ”Έ OAuth2 PKCE Flow
final pkce = createPkcePair();
final authUrl = Uri.parse('https://auth.example.com/authorize').replace(queryParameters: {
  'response_type': 'code',
  'client_id': 'your-client-id',
  'redirect_uri': 'com.example.app:/oauthredirect',
  'scope': 'openid profile offline_access',
  'code_challenge': pkce.codeChallenge,
  'code_challenge_method': 'S256',
  'state': pkce.state,
});

// After redirect and code received:
final tokens = await authService.exchangeAuthorizationCode(
  code: 'returned-code',
  codeVerifier: pkce.codeVerifier,
  redirectUri: Uri.parse('com.example.app:/oauthredirect'),
);

#πŸ”Έ Make authorized requests
final request = http.Request('GET', Uri.parse('https://api.example.com/user'));
final authed = await authService.authorizedRequest(request);
final response = await authed.send();

#πŸ”Έ Sign out
await authService.signOut();
4
likes
160
points
381
downloads

Publisher

verified publisherquinttechco.com

Weekly Downloads

A secure, lightweight authentication package for Flutter (REST + OAuth2 PKCE + token refresh) with secure local storage.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

crypto, flutter, flutter_secure_storage, http, json_annotation, lints, uuid

More

Packages that depend on flutter_secure_auth