android_sign_in_kit 0.2.0
android_sign_in_kit: ^0.2.0 copied to clipboard
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 theACCESS_NETWORK_STATEpermission (granted without asking). signIn: one sheet with saved passwords, passkeys and Google accounts, returning a sealedSignInCredential(GoogleAccount,SavedPasswordorPasskeyCredential). Google accounts are left out when offline.- Passkeys:
createPasskey,signInWithPasskey,upgradeToPasskey(conditional create after a password login), and the signalssignalUnknownPasskey,signalAcceptedPasskeysandsignalUserDetails. New codeCredentialErrorCode.passkeyExists. - Restore keys:
createRestoreKey,getRestoreKeyandclearRestoreKey, to sign users back in on a new phone or after a reinstall. getDigitalCredentialfor digital IDs from a wallet (OpenID4VP).currentUser,isSignedInandauthStateChanges: the Google user, kept across restarts (profile only, never a token).getIdTokenreturns a fresh ID token, signing in again the lightweight way when it expires.getAccessTokenreturns an access token for scopes, withforceRefreshafter a 401.createNonceandNonce: a random nonce and its SHA-256.revokeAccessdisconnects the app from the Google account and signs out.openPasswordSettingsopens the password manager settings (Android 14+), fornoProvider.onlyOnDeviceonsignIn,getPasswordandsignInWithPasskey: fail at once without UI when there is nothing to offer.checkSetupandSetupReport: the package name, SHA-1 and SHA-256 of the running build, the Web client ID, Play services, and the passkey domain'sassetlinks.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).FakeAndroidSignInKitinpackage: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 (
fundingin 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.GoogleAccounthas everything Credential Manager returns plus the ID token's claims: Google user ID (id),emailVerified,hostedDomain,issuedAt,expiresAt,nonceand the fullclaimsmap.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 withGoogleScopeconstants (or any scope URL), with access token, granted scopes and an optional server auth code.- The Web client ID is read from
google-services.jsonwhen 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 returnsPasswordSaveResult.saved,unchangedordeclined. Known logins are remembered across restarts as keyed hashes (HMAC with an Android Keystore key), never as passwords.savePasswordends any autofill session first, so apps that keepautofillHintsshow one save prompt instead of two.signOut: clears the Credential Manager sign-in state.CredentialManagerExceptionwith aCredentialErrorCode, a plain-wordsmessage, and Android'splatformMessage,platformTypeandstatusCode. A closed sheet returns null (ordeclined) 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.
