twitter_oauth2_pkce 0.0.1 copy "twitter_oauth2_pkce: ^0.0.1" to clipboard
twitter_oauth2_pkce: ^0.0.1 copied to clipboard

outdated

Provides the easiest way to authenticate with the Twitter API using the OAuth 2.0 PKCE method in Dart and Flutter.

example/lib/main.dart

import 'package:example/scope.dart';
import 'package:example/twitter_oauth2.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MaterialApp(home: Example()));
}

class Example extends StatefulWidget {
  const Example({Key? key}) : super(key: key);

  @override
  State<Example> createState() => _ExampleState();
}

class _ExampleState extends State<Example> {
  String? _accessToken;
  String? _refreshToken;

  @override
  Widget build(BuildContext context) => Scaffold(
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Text('Access Token: $_accessToken'),
              Text('Refresh Token: $_refreshToken'),
              ElevatedButton(
                onPressed: () async {
                  final oauth2 = TwitterOAuth2(
                    clientId: 'YOUR_CLIENT_ID',
                    clientSecret: 'YOUR_CLIENT_SECRET',
                    redirectUri: 'org.example.android.oauth://callback/',
                    customUriScheme: 'org.example.android.oauth',
                  );

                  final response = await oauth2.executeAuthCodeFlowWithPKCE(
                    scopes: Scope.values,
                  );

                  super.setState(() {
                    _accessToken = response.accessToken;
                    _refreshToken = response.refreshToken;
                  });
                },
                child: const Text('Push!'),
              )
            ],
          ),
        ),
      );
}
16
likes
0
points
143
downloads

Publisher

verified publishershinyakato.dev

Weekly Downloads

Provides the easiest way to authenticate with the Twitter API using the OAuth 2.0 PKCE method in Dart and Flutter.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, oauth2_client

More

Packages that depend on twitter_oauth2_pkce