'Flutter - Firebase - Twitter Authentication issue

I am Trying to Authenticate twitter using flutter and firebase. but not able to landing back on my application page after Authorizing on twitter.

Images: 001 001 : launch app login button will redirect to Twitter page(image 002)

002from twitter page when I click on Authorize app it switches to Image 003 "social_demo" which is app label in my androidmenifest.xml.

003then I click back and it redirect to twitter page with error message Image 004.

004finally if I close this or click back, I got debug message in app "TwitterLoginStatus.cancelledByUser".

Steps are:

redirect to twitter from app

  Future signInWithTwitter() async {
    final twitterLogin = TwitterLogin(
      apiKey: "xxxxxxxxxx",
      apiSecretKey: "xxxxxxxxx",
      redirectURI: 'flutter-twitter-auth://',
    );

    await twitterLogin.login().then((value) {
      debugPrint(value.status.toString());
    });
message => TwitterLoginStatus.cancelledByUser

Androidmenifest.xml

   <intent-filter>
               <action android:name="android.intent.action.VIEW" />
               <category android:name="android.intent.category.DEFAULT" />
               <category android:name="android.intent.category.BROWSABLE" />

               <data android:scheme="flutter-twitter-auth"/>

           </intent-filter>

pubspec.yaml

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.4
  firebase_auth: ^3.2.0
  google_sign_in: ^5.2.1
  google_fonts: ^2.1.0
  flutter_facebook_auth: ^3.5.6
  twitter_login: ^4.0.1

looking for solution... if anyone come across to this.

Twitter: Twitter



Solution 1:[1]

I was facing the same problem, (Went through twitter_login: ^4.0.1 documentation) found the culprits.

<data android:scheme="flutter-twitter-auth"/>

Replace the above with,

<data android:scheme="your_app_name"/>

also replace the below snippet

final twitterLogin = TwitterLogin(
      apiKey: "xxxxxxxxxx",
      apiSecretKey: "xxxxxxxxx",
      redirectURI: 'flutter-twitter-auth://',
    );

with

final twitterLogin = TwitterLogin(
      apiKey: "xxxxxxxxxx",
      apiSecretKey: "xxxxxxxxx",
      redirectURI: 'your_app_name://',
    );

and finally callback URL in twitter developer account should be,

your_app_name://

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 GOKU