firebase_auth_dart_platform library
An implementation of FlutterFire's Firebase Auth platform interface on top
of the pure-Dart client firebase_auth_providers_dart.
An app keeps the official firebase_auth API
(FirebaseAuth.instance.signInWithEmailAndPassword(...)), and
FirebaseUserAuth of firebase_auth_providers_dart does the work
underneath, over the Firebase Auth REST API:
- On Linux, where neither
firebase_authnorfirebase_corehas an implementation, adding this package is enough: Flutter calls FirebaseAuthDart.registerWith beforemain. - On any other platform, call FirebaseAuthDart.use at the start of
main, before the first use of Firebase, to replace the official implementation.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
FirebaseAuthDart.use();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
await FirebaseAuth.instance.signInAnonymously();
}
Classes
- AppVerification
-
The proof that a phone request comes from a real app, sent with
accounts:sendVerificationCodeand the start of an SMS second factor. - CallbackPresenter
-
Shows a flow with a function the app supplies. Needs
dart:iofor the loopback server; on this platform a flow run with it throws an UnsupportedError. - ConsolePresenter
-
A terminal. Needs
dart:io; on this platform show and prompt throw an UnsupportedError. - DartFirebaseAuth
-
The implementation of
FirebaseAuthPlatformon top ofFirebaseUserAuthoffirebase_auth_providers_dart: one client per FlutterFire app. - FirebaseAuthDart
-
Selects
firebase_auth_providers_dartas the implementation of the officialfirebase_authpackage. - OAuthAuthorizationCode
- The authorization code of a loopback sign-in, with what the token endpoint wants next to it (RFC 6749 section 4.1.3 and RFC 7636): the server that exchanges it needs all four.
- OAuthLoopbackProvider
-
An identity provider for the browser sign-in of desktop apps and command line tools
(
authorizeWithOAuthLoopbackandFirebaseUserAuth.signInWithOAuthLoopback, VM only): the OAuth 2.0 authorization code flow with PKCE (S256) whose redirect comes back to a one-shot HTTP server on 127.0.0.1 (RFC 8252, "OAuth 2.0 for Native Apps"). - SecurePresenter
-
A way to show a flow to the person and to collect its answer. Flows choose and drive
presenters (
SecureFlow.run); what a presenter can do is told by the interfaces it implements: - SystemBrowserPresenter
-
Shows a flow in the system browser. Needs
dart:io; on this platform show throws an UnsupportedError.
Functions
-
defaultSessionFile(
) → String? - No file system here: there is no default file.
Typedefs
- AuthStorageFactory = AuthStorage Function(FirebaseApp app)
-
Returns the storage of the session of the FlutterFire
app(seeFirebaseAuthDart.use). -
OAuthCodeExchange
= FutureOr<
Map< Function(OAuthAuthorizationCode code)String, Object?> > -
Exchanges an authorization code for the provider's tokens somewhere else than at the token endpoint: on a server
of yours that holds the client secret. It returns the JSON object of the token endpoint (
id_token,access_token,expires_in, ...). Throw aFirebaseAuthExceptionto choose the error of the sign-in; any other error becomesinvalid-credential. -
OAuthProvidersFactory
= Iterable<
OAuthLoopbackProvider> Function(FirebaseApp app) -
Returns the loopback providers of the FlutterFire
app(seeFirebaseAuthDart.use).
Exceptions / Errors
- DartFirebaseAuthException
-
A
FirebaseAuthExceptionof the platform interface that also keeps what the server answered, for logs:firebase_authpasses it to the app as it is, socatch (e)can teste is DartFirebaseAuthException.