Package selection guidance compiled from public package information, community data, and project usage.
Simple Auth is a lightweight Flutter package designed to streamline user authentication for apps and APIs. It provides a simple, consistent interface for handling login flows, token management, and session persistence across multiple platforms. Built with ease of integration in mind, it supports common authentication methods like OAuth2, JWT, and custom login workflows. The package abstracts away complex implementation details, making it ideal for developers seeking a minimal yet effective authentication solution without boilerplate code.
Use cases
User login with OAuth2
API token management
Session persistence
Custom authentication flows
Cross-platform auth
Quick prototyping
Key features
Minimal setup
Supports multiple auth types
Cross-platform compatibility
Token storage utilities
Clean API design
Built-in session handling
Suitable for
Beginner Flutter developers
Apps needing basic auth
Rapid app development
Multi-platform projects
Teams prioritizing simplicity
Considerations
Limited advanced features
Not suitable for enterprise-scale auth
No built-in UI components
Depends on external auth providers
Less control over low-level logic
Best for simple use cases only
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.