auth library
Authentication for the module, on the same firebase::App the Database
uses.
There is no token to pass along: the SDK routes the credential through the
App, so signing in here is what makes an already-open onValue listener
re-authorize and stop failing with "permission denied".
Classes
- AuthOutcome
- What a sign-in returned.
Functions
-
currentUid(
) → String? - The signed-in uid, or null.
-
idToken(
{bool forceRefresh = false}) → Future< String> - Custom-token sign-in — the right shape for a device.
-
initAuth(
) → void -
restoredUid(
{Duration timeout = const Duration(seconds: 3), Duration interval = const Duration(milliseconds: 50)}) → Future< String?> - Waits briefly for a persisted session to be restored, returning its uid.
-
signInAnonymously(
) → Future< AuthOutcome> - Anonymous sign-in. The project must have the Anonymous provider enabled.
-
signInWithCustomToken(
String token) → Future< AuthOutcome> - database rules key off, so a rule can say "this device" rather than "anyone signed in".
-
signOut(
) → void -
useAuthEmulator(
String host, int port) → void - Prepares Auth on the shared App. initDatabase must have run first. Points Auth at a local emulator. Call after initAuth and before signing in — the SDK reconfigures the endpoint rather than migrating a session that already exists.
Exceptions / Errors
- AuthException
- Raised when a sign-in fails, carrying the SDK's own code and message rather than a generic failure — an auth error is nearly always actionable (provider disabled, token malformed, clock skew) and only the SDK knows which.