twitter_auth_v2 1.0.4-beta.2 twitter_auth_v2: ^1.0.4-beta.2 copied to clipboard
Package for twitter authentication.
twitter_auth_v2 #
Flutter package for twitter authentication. twitter_auth_v2
Twitter Configuration #
- Create twitter app documentation
- Add callback url
app://example
Android Configuration #
Add intent as follows:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accept redirect url like "app://example" -->
<data android:scheme="app"
android:host="example" />
</intent-filter>
IOS Configuration #
Change Info.plist as follows
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>app</string>
</array>
</dict>
</array>
Usage #
To use this plugin, add twitter_auth_v2
as a dependency in your pubspec.yaml file.
void _authentication() async {
final TwitterAuthClient client = TwitterAuthClient(
callbackUrlScheme: '[CALLBACK_SCHEME]',
clientId: '[CLIENT_ID]',
clientSecret: '[CLIENT_SECRET]',
navigatorKey: navigatorKey,
loader: const Center(
child: CircularProgressIndicator(),
),
redirectUri: '[REDIRECT_URI]');
TwitterAuthResult? data = await client.login(scopes: TwitterScope.values);
if (data == null) return;
setState(() {
_token = data.accessToken;
_refreshToken = data.refreshToken;
_expireIn = data.expiresIn.toString();
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Access Token: $_token',
),
Text(
'Refresh Token: $_refreshToken',
),
Text(
'Expire In: $_expireIn',
),
ElevatedButton(
onPressed: _authentication, child: const Text('Authentication'))
],
),
),
);
}
Licence #
Contributions of any kind are welcome!