https://github.com/robertodoering/twitter_webview_auth
Twitter oauth1 webview authentication implemention using webview_flutter
https://github.com/robertodoering/twitter_webview_auth
Last synced: 4 months ago
JSON representation
Twitter oauth1 webview authentication implemention using webview_flutter
- Host: GitHub
- URL: https://github.com/robertodoering/twitter_webview_auth
- Owner: robertodoering
- License: gpl-2.0
- Created: 2022-02-08T22:22:18.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-11-17T18:45:34.000Z (over 1 year ago)
- Last Synced: 2026-01-18T23:56:48.304Z (4 months ago)
- Language: Dart
- Size: 26.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Twitter oauth1 webview authentication for Flutter
[](https://pub.dev/packages/twitter_webview_auth)
This Flutter package implements the 3-legged oauth authentication flow using [webview_flutter](https://pub.dev/packages/webview_flutter).
## Getting started
- Get access to the [Twitter API](https://developer.twitter.com/en/docs/twitter-api/getting-started/getting-access-to-the-twitter-api) and create a 'Standalone App' in the [Twitter developer portal](https://developer.twitter.com/en/portal/projects-and-apps)
- Enable `OAuth 1.0a` for your app
- Enter a callback url. This can be any arbitrary url or just the scheme
- e.g. `app://`
## Usage
```dart
final TwitterAuthResult result = await TwitterAuth(
consumerKey: 'your_consumer_key',
consumerSecret: 'your_consumer_secret',
callbackUrl: 'your_callback_url',
).authenticateWithTwitter(
webviewNavigation: (Widget webview) => Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => Scaffold(
appBar: AppBar(title: const Text('Login')),
body: webview,
),
),
),
);
result.when(
success: (String token, String secret, String userId) {
// user successfully authenticated
},
failure: (dynamic e, StackTrace? st) {
// authentication failed
},
cancelled: () {
// authentication has been cancelled by the user
},
);
```
## Additional information
For making requests to the Twitter API, check out [dart_twitter_api](https://pub.dev/packages/dart_twitter_api)