oauth1
2.1.0, released 2 years ago by an unverified publisher
OAuth 1.0 client implementation for Dart
WASM-readyUnverified publisher
What it does
Provides classes to perform the OAuth 1.0 flow, request temporary credentials, authorize the user, and obtain access tokens to call protected APIs.
AI-written summary of version 2.1.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- Need OAuth 1.0 authentication for services like Twitter
- Integrating with legacy APIs that require OAuth 1.0
Skip it when
- Using OAuth 2.0 only
- Already have another OAuth1 library
Strengths
- Supports null safety
- Compatible with http package
- Simple, straightforward API
Weaknesses
- No code generation support
- Limited to OAuth 1.0 only
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
import 'dart:io';
import 'package:oauth1/oauth1.dart' as oauth1;
void main() {
var platform = oauth1.Platform(
'https://api.twitter.com/oauth/request_token',
'https://api.twitter.com/oauth/authorize',
'https://api.twitter.com/oauth/access_token',
oauth1.SignatureMethods.hmacSha1,
);
const String apiKey = 'YOUR_KEY';
const String apiSecret = 'YOUR_SECRET';
var clientCredentials = oauth1.ClientCredentials(apiKey, apiSecret);
var auth = oauth1.Authorization(clientCredentials, platform);
auth.requestTemporaryCredentials('oob').then((res) {
print('Open browser: ${auth.getResourceOwnerAuthorizationURI(res.credentials.token)}');
stdout.write('PIN: ');
String verifier = stdin.readLineSync();
return auth.requestTokenCredentials(res.credentials, verifier);
}).then((res) {
var client = oauth1.Client(platform.signatureMethod, clientCredentials, res.credentials);
client.get('https://api.twitter.com/1.1/statuses/home_timeline.json?count=1').then((res) {
print(res.body);
});
});
}Alternatives
Packages that do the same job and could replace oauth1.
- firebase_ui_oauth
Firebase UI OAuth widgets for authentication with social providers
84Compare - firebase_ui_oauth_google
Flutter widgets for Google OAuth sign‑in using Firebase UI.
81Compare - firebase_ui_oauth_apple
Firebase UI widgets for Sign in with Apple authentication.
77Compare - flutter_web_auth_2
Flutter plugin for authenticating a user with a web service.
93Compare
Works with
Packages commonly used together with oauth1: ones it builds on, ones built on it, and its own family.