credential_manager

Creator: coderz1093

Last updated:

Add to Cart

Description:

credential manager

Credential Manager #
Credential Manager is a Jetpack API that supports multiple sign-in methods, such as username and password, passkeys, and federated sign-in solutions (like Sign-in with Google) in a single API, simplifying integration for developers.
For users, Credential Manager unifies the sign-in interface across authentication methods, making it clearer and easier to sign into apps, regardless of the chosen method.

Note: This package is currently only supported for Android.

Getting Started #
Add the dependency to your pubspec.yaml file:
credential_manager: <latest_version>

copied to clipboard
Or run:
flutter pub add credential_manager
copied to clipboard
Setup Android #


Add proguard rules:
Create or update android/app/proguard-rules.pro:
-if class androidx.credentials.CredentialManager
-keep class androidx.credentials.playservices.** {
*;
}
copied to clipboard


Update android/app/build.gradle:
android {
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
copied to clipboard


Usage in Flutter #


Import the package:
import 'package:credential_manager/credential_manager.dart';
copied to clipboard


Create a CredentialManager instance:
CredentialManager credentialManager = CredentialManager();
copied to clipboard


Check if the platform is supported:
if (credentialManager.isSupportedPlatform) {
// Supported
}
copied to clipboard


Initialize the Credential Manager:
await credentialManager.init(
preferImmediatelyAvailableCredentials: true,
googleClientId: googleClientId // Optional for Google Sign-In
);
copied to clipboard


Save credentials:
await credentialManager.savePasswordCredentials(
PasswordCredential(username: username, password: password)
);
copied to clipboard


Save Google credentials:
final GoogleIdTokenCredential? gCredential = await credentialManager.saveGoogleCredential();
copied to clipboard
For Google button flow:
await credentialManager.saveGoogleCredential(useButtonFlow: true);
copied to clipboard




Get saved credentials:
Credentials credential = await credentialManager.getPasswordCredentials();
copied to clipboard




Logout:
await credentialManager.logout();
copied to clipboard


Encrypt Your Credentials #
To enhance security, you can encrypt the password field:
Encrypt Your Credentials #
To enhance security, you can encrypt the password field:
dart
final secretKey = "<Secret-key>"; // 16-character string
final ivKey = "<16-bit-iv-key>";
// Save encrypted credentials
await credentialManager.saveEncryptedCredentials(
credential: PasswordCredential(username: username, password: password),
secretKey: secretKey,
ivKey: ivKey
);
// Get and decrypt credentials
Credentials credential = await credentialManager.getEncryptedCredentials(
secretKey: secretKey,
ivKey: ivKey
);
copied to clipboard
Additional Setup #

Google Sign-In Setup (optional)
Passkey Integration (optional)

Error Handling #
For detailed error codes and messages, see Error Handler.
Properties and Methods #
For a complete list of properties and methods, see Properties and Methods.
Upcoming Features #

iOS Support

Contributing #
Contributions are welcome! Please see the Contributing Guidelines for more details.
If you find this package useful, please:

Star it on GitHub
Tweet about it
Mention it in your blog posts

For bug reports, feature requests, or questions, please open an issue on GitHub.

License

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

Files:

Customer Reviews

There are no reviews.