Simple Auth is the simplest way to authenticate your users/apis. This plugin will securely store tokens/credentials as well as automatically present login UI when needed.
Package selection guidance compiled from public package information, community data, and project usage.
Simple Auth Flutter is a lightweight authentication package that simplifies user authentication in Flutter apps. It securely stores tokens and credentials, automatically handles login UI presentation when required, and integrates seamlessly with various identity providers. Designed for ease of use, it reduces boilerplate code while maintaining security best practices. The plugin supports Android, iOS, and macOS, making it ideal for cross-platform applications needing straightforward auth workflows.
Use cases
User login and session management
Automatic re-authentication
Secure token storage
Integration with OAuth providers
Cross-platform authentication
Key features
Secure credential storage
Auto-login UI prompt
Minimal setup
Supports multiple platforms
Built-in token persistence
Suitable for
Beginner Flutter developers
Apps requiring basic auth
Projects with tight deadlines
Cross-platform mobile apps
Simple login flows
Considerations
Limited customization for login screens
Not suitable for complex auth workflows
Depends on external provider implementations
No built-in user registration
Requires careful handling of token refresh logic
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Most apps need to make API calls. Every API needs authentication, yet no developer wants to deal with authentication. Simple Auth embeds authentication into the API so you dont need to deal with it.
And of course any standard OAuth2/Basic Auth server.
Usage
var api = new simpleAuth.GoogleApi(
"google", "client_id",clientSecret: "clientSecret",
scopes: [
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile"
]);
var request = newRequest(HttpMethod.Get, "https://www.googleapis.com/oauth2/v1/userinfo?alt=json");
var userInfo = await api.send<UserInfo, UserInfo>(request);
That's it! If the user is not logged in, they will automatically be prompted. If their credentials are cached from a previous session, the api call proceeds! Expired tokens even automatically refresh.
Flutter Setup
Call SimpleAuthFlutter.init(); in your Main.Dart. Now Simple Auth can automatically present your login UI
Redirect
Google requires the following redirect: com.googleusercontent.apps.YOUR_CLIENT_ID
Simple Auth by default uses SFSafari on iOS and Chrome Tabs on Android.
This means normal http redirects cannot work. You will need to register a custom scheme for your app as a redirect. For most providers, you can create whatever you want. i.e. com.myapp.foo:/redirct
Android Manifest
you would then add the following to your Android manifest
Note, if you want to avoid Apples mandatory user consent dialog
"foo" Wants to use "bar.com" to Sign In
This allows the app and website to share information about you.
add the lines above and set FooAuthenticator.useSSO = false; which will not use SFAuthenticationSession on iOS, and ASWebAuthenticationSession on macOS. This is the default behavior for the Keycloak provider.
Serialization
Json objects will automatically serialize if you conform to JsonSerializable
If you use the generator and you objects have the factory factory JsonSerializable.fromJson(Map<String, dynamic> json) your api calls will automatically Serialize/Deserialize
Or you can pass your own Converter to the api and handle conversion yourself.