Flutter

Secure Storage

SecureAuthStorage, the production AuthStorage implementation for Flutter, backed by Keychain and Keystore.

SecureAuthStorage is the ready-to-use AuthStorage implementation for Flutter apps, wrapping flutter_secure_storage.

import 'package:authyra_flutter/authyra_flutter.dart';

await Authyra.initialize(
  client: AuthyraClient(
    providers: [...],
    storage: SecureAuthStorage(),
  ),
);

No configuration is required for most apps. It selects the platform-native encrypted store automatically:

PlatformBackend
iOS / macOSKeychain
AndroidEncryptedSharedPreferences (Android Keystore)
WeblocalStorage with Web Crypto AES-GCM, per-origin key
Linuxlibsecret (Secret Service)
WindowsDPAPI (CryptProtectData)

Custom platform options

Pass flutter_secure_storage's own option classes to tune behaviour per platform:

SecureAuthStorage(
  aOptions: const AndroidOptions(
    encryptedSharedPreferences: true,
    resetOnError: true, // wipe rather than crash on decryption failure
  ),
)

Android setup

minSdkVersion must be 18 or above in android/app/build.gradle:

android {
  defaultConfig {
    minSdkVersion 18
  }
}

Web setup

No extra configuration. flutter_secure_storage on web uses the browser's SubtleCrypto API with a key scoped to your origin.


What gets stored

SessionManager persists one entry per signed-in account under session:{userId}, plus a small index for the active account. Every entry contains that account's AuthSession JSON, including access and refresh tokens, so the underlying encryption matters: don't swap in a plaintext implementation.


See also

Copyright © 2026