oauth_dio
0.2.9, released 3 years ago by an unverified publisher
A customizable OAuth client for Dio with token storage and interceptors
What it does
Provides an OAuth client that can request, refresh, and store tokens, and injects bearer tokens into Dio requests via interceptors. It supports custom grant types and pluggable storage.
AI-written summary of version 0.2.9, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need OAuth 2.0 authentication with Dio in a Flutter or Dart app
- You want to persist tokens securely on the device
- You need custom grant types beyond the standard ones
Skip it when
- You are using the http package instead of Dio
- You need a full authentication flow with UI (e.g., Google Sign-In)
- You prefer a higher-level auth SDK like firebase_auth
Strengths
- Easy integration with Dio
- Supports custom grant types
- Pluggable storage (memory, secure storage, etc.)
- Simple API for token requests and refresh
Weaknesses
- No built-in UI for sign-in
- Limited to Dio; not usable with http directly
- No support for device authentication methods like biometrics
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
Add dependency, optionally add flutter_secure_storage for secure token storage, create OAuth instance, add BearerInterceptor to Dio
final oauth = OAuth(tokenUrl: 'https://example.com/token', clientId: 'id', clientSecret: 'secret');
final dio = Dio();
dio.interceptors.add(BearerInterceptor(oauth));Alternatives
Packages that do the same job and could replace oauth_dio.
- google_sign_in
Provides Google OAuth with UI and platform integration
84Compare - firebase_auth
Full-featured auth with multiple providers and UI support
99Compare
Works with
Packages commonly used together with oauth_dio: ones it builds on, ones built on it, and its own family.