Skip to main content

android_sign_in_kit 0.2.0 copy "android_sign_in_kit: ^0.2.0" to clipboard
android_sign_in_kit: ^0.2.0 copied to clipboard

PlatformAndroid

Google Sign-In, passkeys and saved passwords in one sheet through Android's Credential Manager, with scopes, restore keys and a setup checker.

0.2.0 #

Breaking: a closed sheet now throws CredentialManagerException with the new code CredentialErrorCode.canceled, instead of returning null. This applies to signInWithGoogle, getPassword and authorize (where the user declines). savePassword still returns PasswordSaveResult.declined, and attemptLightweightSignIn still returns null. Off Android, every method still returns null without throwing.

  • No internet is now CredentialErrorCode.network. Google's sheet closes by itself without internet, and Android reported that as a cancel; the package now checks the connection, and says so at once instead of opening the sheet. Adds the ACCESS_NETWORK_STATE permission (granted without asking).
  • signIn: one sheet with saved passwords, passkeys and Google accounts, returning a sealed SignInCredential (GoogleAccount, SavedPassword or PasskeyCredential). Google accounts are left out when offline.
  • Passkeys: createPasskey, signInWithPasskey, upgradeToPasskey (conditional create after a password login), and the signals signalUnknownPasskey, signalAcceptedPasskeys and signalUserDetails. New code CredentialErrorCode.passkeyExists.
  • Restore keys: createRestoreKey, getRestoreKey and clearRestoreKey, to sign users back in on a new phone or after a reinstall.
  • getDigitalCredential for digital IDs from a wallet (OpenID4VP).
  • currentUser, isSignedIn and authStateChanges: the Google user, kept across restarts (profile only, never a token).
  • getIdToken returns a fresh ID token, signing in again the lightweight way when it expires. getAccessToken returns an access token for scopes, with forceRefresh after a 401.
  • createNonce and Nonce: a random nonce and its SHA-256.
  • revokeAccess disconnects the app from the Google account and signs out.
  • openPasswordSettings opens the password manager settings (Android 14+), for noProvider.
  • onlyOnDevice on signIn, getPassword and signInWithPasskey: fail at once without UI when there is nothing to offer.
  • checkSetup and SetupReport: the package name, SHA-1 and SHA-256 of the running build, the Web client ID, Play services, and the passkey domain's assetlinks.json, with what to fix.
  • GoogleSignInButton: a "Sign in with Google" button following Google's branding guidelines (light, dark and neutral; pill or rectangular; four texts; icon-only; loading).
  • FakeAndroidSignInKit in package:android_sign_in_kit/testing.dart, to test login screens without Android.
  • The example app shows all of it, with passkeys for a demo domain.
  • Doc comments for every public constructor and field.

0.1.1 #

  • Added a Buy Me a Coffee link (funding in pubspec and a Support section in the README).

0.1.0 #

  • initialize: gets the Google and password sheets ready in the background (Android 14+), so they open on tap instead of after a pause. It also stores the Web client ID and the default sheet options.
  • signInWithGoogle: Google Sign-In with the account bottom sheet, or Google's "Sign in with Google" button flow. Options for auto-select, previous accounts only, Workspace domain, nonce and scopes.
  • GoogleAccount has everything Credential Manager returns plus the ID token's claims: Google user ID (id), emailVerified, hostedDomain, issuedAt, expiresAt, nonce and the full claims map.
  • attemptLightweightSignIn: signs a returning user in with as little UI as possible, or returns null without showing anything.
  • authorize: OAuth scopes through Google's Authorization API, picked with GoogleScope constants (or any scope URL), with access token, granted scopes and an optional server auth code.
  • The Web client ID is read from google-services.json when it isn't passed, for Firebase apps.
  • getPassword: pick a saved login from the bottom sheet. It can fill your text fields (usernameController, passwordController) and log in straight away (onPicked), or only fill.
  • savePassword: offers "Save password?" only for a new or changed password, and returns PasswordSaveResult.saved, unchanged or declined. Known logins are remembered across restarts as keyed hashes (HMAC with an Android Keystore key), never as passwords.
  • savePassword ends any autofill session first, so apps that keep autofillHints show one save prompt instead of two.
  • signOut: clears the Credential Manager sign-in state.
  • CredentialManagerException with a CredentialErrorCode, a plain-words message, and Android's platformMessage, platformType and statusCode. A closed sheet returns null (or declined) instead of throwing.
  • Safe on every platform: off Android the methods do nothing and return null (or PasswordSaveResult.unsupported), so shared code needs no platform checks. Autofill hint getters (usernameAutofillHints, passwordAutofillHints, emailAutofillHints, newUsernameAutofillHints, newPasswordAutofillHints) keep iOS keychain autofill working without competing with Credential Manager on Android.
  • R8 rules included for release builds.
1
likes
150
points
267
downloads
screenshot

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Google Sign-In, passkeys and saved passwords in one sheet through Android's Credential Manager, with scopes, restore keys and a setup checker.

Repository (GitHub)
View/report issues

Topics

#google-sign-in #credential-manager #passkeys #password #authentication

Funding

Consider supporting this project:

buymeacoffee.com

License

MIT (license)

Dependencies

flutter

More

Packages that depend on android_sign_in_kit

Packages that implement android_sign_in_kit