Getting started
Installation
Pick the packages your app needs and set up the platforms.
Pick your packages
A Flutter app needs authyra_flutter, which re-exports the core. Add the others for what you use:
flutter pub add authyra_flutter
flutter pub add authyra_dio # if your app uses Dio
flutter pub add authyra_google # native Google Sign-In
flutter pub add authyra_apple # native Sign in with Apple
A pure Dart program (a CLI, a server calling another API) uses the core alone:
dart pub add authyra
Requirements
| Package | Dart | Flutter |
|---|---|---|
authyra | 3.5 | none |
authyra_dio | 3.8 | none |
authyra_flutter | 3.8 | 3.24 |
authyra_apple | 3.8 | 3.24 |
authyra_google | 3.8 | 3.27 |
Platform setup
Only what you use needs setting up.
Secure storage
SecureAuthStorage is built on flutter_secure_storage. Follow its platform notes, in particular:
- macOS: add the Keychain Sharing capability (
keychain-access-groupsentitlement), or reads and writes fail. - Linux: install
libsecret-1-devto build, and a secret service (GNOME Keyring, KWallet) at runtime. - Web: storage relies on WebCrypto and is not a secure enclave. Treat tokens on the web as readable by any script running on your origin.
Browser-based sign-in
OAuth2Provider and BackendOAuthProvider open a secure browser session with flutter_web_auth_2. Your redirect URI uses a custom scheme such as com.example.app:/oauth-callback:
- iOS and macOS: nothing to configure,
ASWebAuthenticationSessioncaptures the scheme. - Android: declare the callback activity for your scheme in
AndroidManifest.xml, as described in theflutter_web_auth_2README. - Web: serve the small callback page from the same origin.
No deep-link routing is needed in your app: the browser session returns the redirect URL directly to the sign-in call.