I keep getting this error while trying to set the Twitter authentification on my Flutter application.
Here's the error:
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(400, Failed to generate request token., Please check your APIKey or APISecret., null)
Here's my function :
Future<UserCredential> signInWithTwitter() async {
final twitterLogin = TwitterLogin(
apiKey: '...',
apiSecretKey:'...',
redirectURI: 'http://localhost:8080/auth/twitter/callback',
);
final authResult = await twitterLogin.login();
final twitterAuthCredential = TwitterAuthProvider.credential(
accessToken: authResult.authToken!,
secret: authResult.authTokenSecret!,
);
return await FirebaseAuth.instance.signInWithCredential(twitterAuthCredential);
}
And here's how I call it with a button :
onPressed: () async {
await signInWithTwitter();
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => const NextPage()));
},
Here's my pubspec.yaml:
firebase_core: ^1.12.0
firebase_auth: ^3.3.7
google_sign_in: ^5.2.4
twitter_login: ^4.0.1
Thanks for your help!
Please use check my code below
If you cannot find it, please regenerate your consumer key