Giter Site home page Giter Site logo

twitter_login's Introduction

twitter_login

Pub Version

Flutter Twitter Login Plugin

Requirements

  • Dart sdk: ">=2.12.0-0 <3.0.0"
  • flutter: ">=1.25.0-8.1.pre"
  • Android: minSdkVersion 17 and add support for androidx
  • iOS: --ios-language swift, Xcode version >= 11

Twitter Configuration

Twitter Developer

required to create TwitterApp.
this plugin is need Callback URLs.

please register a different callback URL on Twitter Developers.

app_name://

If the API is not set to get email, email may be null. If you want to use email, turn on Request email address from users.

Android Configuration

Add intent filters for incoming links

/example/android/app/src/main/AndroidManifest.xm

You need to replace the scheme with a Callback URLs.

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  <!-- Accepts URIs that begin with "example://gizmos” -->
  <!-- Registered Callback URLs in TwitterApp -->
  <data android:scheme="example"
        android:host="gizmos" /> <!-- host is option -->
</intent-filter>

Supporting the new Android plugins APIs

If you flutter created your project prior to version 1.12, you need to make sure to update your project in order to use the new Java Embedding API.
Make use you have flutter_embedding v2 enabled. Add the following code on the manifest file inside tag to enable embedding.
Flutter wiki: Upgrading pre 1.12 Android projects.

<meta-data
    android:name="flutterEmbedding"
    android:value="2" />

iOS Configuration

Add URLScheme

/example/ios/Runner/Info.plist

You need to replace the example with a Callback URLs.

<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLName</key>
    <string></string>
    <key>CFBundleURLSchemes</key>
    <array>
      <!-- Registered Callback URLs in TwitterApp -->
      <string>example</string>
    </array>
  </dict>
</array>

Example code

See the example directory for a complete sample app using twitter_login.

example

Usage

To use this plugin, add twitter_login as a dependency in your pubspec.yaml file.

Example

import 'package:flutter/material.dart';
import 'package:twitter_login/twitter_login.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Twitter Login App'),
        ),
        body: Center(
          child: FlatButton(
            child: Text('Login With Twitter'),
            onPressed: () async {
              final twitterLogin = TwitterLogin(
                // Consumer API keys
                apiKey: 'xxxx',
                // Consumer API Secret keys
                apiSecretKey: 'xxxx',
                // Registered Callback URLs in TwitterApp
                // Android is a deeplink
                // iOS is a URLScheme
                redirectURI: 'example://',
              );
              final authResult = twitterLogin.login();
              switch (authResult.status) {
                case TwitterLoginStatus.loggedIn:
                  // success
                  break;
                case TwitterLoginStatus.cancelledByUser:
                  // cancel
                  break;
                case TwitterLoginStatus.error:
                  // error
                  break;
              }
            },
          ),
        ),
      ),
    );
  }
}

twitter_login's People

Contributors

0maru avatar dcrebbin avatar katsuyax avatar mj-hd avatar mocha-coffee-jp avatar mono0926 avatar riscait avatar saifallak avatar terubooon avatar tsuruobiz avatar volyx avatar xmkevinchen avatar xrayadamo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

twitter_login's Issues

The getter 'status' isn't defined for the type 'Future<AuthResult>'.

authResult.status not defined

final authResult = twitterLogin.login();
switch (authResult.status) { // status not find
  case TwitterLoginStatus.loggedIn:
    // success
    break;
  case TwitterLoginStatus.cancelledByUser:
    // cancel
    break;
  case TwitterLoginStatus.error:
    // error
    break;
}

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.1, on macOS 11.4 20F71 darwin-arm, locale en)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.57.1)
[✓] Connected device (2 available)

• No issues found!

Encountering Exception "type 'int' is not a subtype of type 'String' Causing a Failed Auth"

I recently started using FlutterFire UI (which depends on 'twitter_login') for my authentication flow for Twitter. My code uses the proper keys and endpoints to the point where I can see that the user has been authenticated and the data for the user returned via the APIs (response of the 1.1 verify_credentials). However, an exception is being caught causing the authentication to fail. The following is the trace:

exception = {_TypeError} type 'int' is not a subtype of type 'String'
#0 new User (user.dart:56)
#1 User.getUserData (user.dart:81)
#2 <async break>null
#3 TwitterLogin.login (twitter_login.dart:149)
#4 <async break>null
#5 TwitterProviderImpl.signIn (twitter_provider.dart:41)
#6 <async break>null
#7 OAuthFlow.signInWithProvider (oauth_flow.dart:37)
#8 <async break>null

Here is my flutter doctor -v for more information on my environment:

[√] Flutter (Channel stable, 2.8.1, on Microsoft Windows [Version 10.0.22000.376], locale en-US)
    • Flutter version 2.8.1 at C:\Users\bclar\Documents\GitRepos\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 77d935af4d (12 days ago), 2021-12-16 08:37:33 -0800
    • Engine revision 890a5fca2e
    • Dart version 2.15.1

[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at C:\Users\bclar\AppData\Local\Android\sdk
    • Platform android-32, build-tools 32.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[√] IntelliJ IDEA Community Edition (version 2021.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart

[√] Connected device (4 available)
    • Pixel 3a (mobile)       • 984AY12VAL    • android-arm64  • Android 12 (API 31)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 96.0.4664.110
    • Edge (web)              • edge          • web-javascript • Microsoft Edge 96.0.1054.43

• No issues found!

I'm not really too sure if this is my problem or if it's something that can be fixed on your side. Please give me any pointers to help me get past this issue. Thank you!

catch an error when canceled on iOS

After taps the cancel button on the login dialog, the result returns with TwitterLoginStatus.error not TwitterLoginStatus.cancelledByUser.

The error message is Null check operator used on a null value.

twitter_login: ^3.0.8
iOS version 14.4.2

Getting "sorry that page does not exist in both android and ios"

Is there anything i am missing?

my androidmanifest.xml

<intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <!-- Accepts URIs that begin with "example://” -->
                <!-- Registered Callback URLs in TwitterApp -->
                <data android:scheme="twittersdk" android:host="" /> <!-- host is option -->
            </intent-filter>

Not able to get email id in twitter.

I have used this package to authenticate with Twitter
I have enabled mark in the Twitter application to get emails.

Future<UserCredential> signInWithTwitter() async {
    // Create a TwitterLogin instance
    final TwitterLogin twitterLogin = new TwitterLogin(
        apiKey: '',
        apiSecretKey: '',
        redirectURI: '//');

    // Trigger the sign-in flow
    // final TwitterLoginResult loginResult = await twitterLogin.authorize();
    //
    // // Get the Logged In session
    // final TwitterSession twitterSession = loginResult.session;

    // Create a credential from the access token\
    final authResult = await twitterLogin.login();

    switch (authResult.status) {
      case TwitterLoginStatus.loggedIn:
        // success
        final AuthCredential twitterAuthCredential =
            TwitterAuthProvider.credential(
                accessToken: authResult.authToken,
                secret: authResult.authTokenSecret);
          // Once signed in, return the UserCredential
        return await FirebaseAuth.instance
            .signInWithCredential(twitterAuthCredential);
        break;
      case TwitterLoginStatus.cancelledByUser:
        throw SignInCancelledException(
            null, "Account exist with different authentication provider.");
        break;
      case TwitterLoginStatus.error:
        throw SignInCancelledException(
            null, "Twitter Authentication Not Performed");
        break;
    }
  }

Build Error on Android build

e: /Applications/flutter/.pub-cache/hosted/pub.dartlang.org/twitter_login-0.0.1/android/src/main/kotlin/com/maru/twitter_login/TwitterLoginPlugin.kt: (3, 28): Conflicting import, imported name 'NonNull' is ambiguous
e: /Applications/flutter/.pub-cache/hosted/pub.dartlang.org/twitter_login-0.0.1/android/src/main/kotlin/com/maru/twitter_login/TwitterLoginPlugin.kt: (5, 28): Conflicting import, imported name 'NonNull' is ambiguous
e: /Applications/flutter/.pub-cache/hosted/pub.dartlang.org/twitter_login-0.0.1/android/src/main/kotlin/com/maru/twitter_login/TwitterLoginPlugin.kt: (75, 3): 'onNewIntent' overrides nothing
e: /Applications/flutter/.pub-cache/hosted/pub.dartlang.org/twitter_login-0.0.1/android/src/main/kotlin/com/maru/twitter_login/TwitterLoginPlugin.kt: (94, 3): 'onAttachedToActivity' overrides nothing
e: /Applications/flutter/.pub-cache/hosted/pub.dartlang.org/twitter_login-0.0.1/android/src/main/kotlin/com/maru/twitter_login/TwitterLoginPlugin.kt: (96, 36): Type mismatch: inferred type is TwitterLoginPlugin but PluginRegistry.NewIntentListener was expected
e: /Applications/flutter/.pub-cache/hosted/pub.dartlang.org/twitter_login-0.0.1/android/src/main/kotlin/com/maru/twitter_login/TwitterLoginPlugin.kt: (99, 3): 'onDetachedFromActivity' overrides nothing
e: /Applications/flutter/.pub-cache/hosted/pub.dartlang.org/twitter_login-0.0.1/android/src/main/kotlin/com/maru/twitter_login/TwitterLoginPlugin.kt: (100, 54): Type mismatch: inferred type is TwitterLoginPlugin but PluginRegistry.NewIntentListener was expected
e: /Applications/flutter/.pub-cache/hosted/pub.dartlang.org/twitter_login-0.0.1/android/src/main/kotlin/com/maru/twitter_login/TwitterLoginPlugin.kt: (104, 3): 'onDetachedFromActivityForConfigChanges' overrides nothing
e: /Applications/flutter/.pub-cache/hosted/pub.dartlang.org/twitter_login-0.0.1/android/src/main/kotlin/com/maru/twitter_login/TwitterLoginPlugin.kt: (105, 54): Type mismatch: inferred type is TwitterLoginPlugin but PluginRegistry.NewIntentListener was expected
e: /Applications/flutter/.pub-cache/hosted/pub.dartlang.org/twitter_login-0.0.1/android/src/main/kotlin/com/maru/twitter_login/TwitterLoginPlugin.kt: (109, 3): 'onReattachedToActivityForConfigChanges' overrides nothing
e: /Applications/flutter/.pub-cache/hosted/pub.dartlang.org/twitter_login-0.0.1/android/src/main/kotlin/com/maru/twitter_login/TwitterLoginPlugin.kt: (111, 36): Type mismatch: inferred type is TwitterLoginPlugin but PluginRegistry.NewIntentListener was expected

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':twitter_login:compileDebugKotlin'.

Compilation error. See log for more details

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 11s
Exception: Gradle task assembleDebug failed with exit code 1

Strange Login Issue

Here is my code:

final TwitterLogin twitterLogin = TwitterLogin(
    apiKey: 'key',
    apiSecretKey: 'secret',
    redirectURI: 'url',
  );
final AuthResult authResult = await twitterLogin.login();

print(authResult.status);
if (authResult.status == TwitterLoginStatus.error ||
    authResult.status == TwitterLoginStatus.cancelledByUser) {
  print(authResult.errorMessage);
  return null;
}

If I enter Email to login twitter, it will direct to this Page Not Found.
simulator_screenshot_A02CC8A5-666E-4391-82F3-B7A6B3007FEE

HOWEVER, if I enter Username to login, it will successfully direct me to correct Authorise page. I think it is a bug from Twitter side.

But after I clicked authorise my app, it failed to get the token. I logged the error message :

I/flutter ( 9869): null
I/flutter ( 9869): type 'Null' is not a subtype of type 'String'

Missing AuthResult when login in Android

Hi,

  • Version 1.0.0 of twitter_login
  • The Android source isn't a flutterEmbedding v2

Everything works fine on iOS.

I had some problems interacting with the webview in Android. I could solve it adding this to the AndroidManifest.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="twittersdk" android:host="" />
</intent-filter>

The current problem is that after the login() execution, nothing more happens when the Android webview is closed:

final AuthResult result = await twitterLogin.login(); // <-- here the webview is opened

if (result.status == TwitterLoginStatus.error) { // <-- never executed, even if the login flow is well
    return null;
}

Could you help me?

No Way To Logout?

Great work! Null safety and everything!
However, and I may be missing something here, no logout routine?

  /// Logs the currently logged-in user out.
  Future<void> logOut() async => channel.invokeMethod('logOut', _keys);

Unable to open custom tabs for twitter auth

In some environments, the custom tab couldn't open.

It works on the android Pixel 4 API30 emulator,
however, It didn't on the android Pixel 3a API30 emulator, Pixel 5 actual device( android 12 ), and another Android device (android11).

Here is the error message.
PlatformException(200, Could not open browser, probably caused by unavailable custom tabs., null, null)

My flutter doctor is following.

`[✓] Flutter (Channel stable, 2.5.1, on Mac OS X 10.14.6 18G9323 darwin-x64,
locale ja-JP)
• Flutter version 2.5.1 at /Users/s.imamura/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ffb2ecea52 (2 weeks ago), 2021-09-17 15:26:33 -0400
• Engine revision b3af521a05
• Dart version 2.14.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/s.imamura/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.60.2)
• VS Code at /Users/s.imamura/Desktop/Visual Studio Code.app/Contents
• Flutter extension version 3.26.0

[✓] Connected device (1 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 94.0.4606.61`

Also, I am using twitter_login 4.0.1

Do you have any idea about how to get out from this error?

witterLoginStatus.error: PlatformException(ChromeBrowserManager, No WebView fallback declared., null, null)

I got TwitterLoginStatus.error: PlatformException(ChromeBrowserManager, No WebView fallback declared., null, null)

It looks like there is no fallback browser, maybe it is connected with this pichillilorenzo/flutter_inappwebview#537

Code

final twitterLogin = TwitterLogin(
        // Consumer API keys
        apiKey: ConfigReader.getTwitterConsumerKey(),
        // Consumer API Secret keys
        apiSecretKey: ConfigReader.getTwitterConsumerSecret(),
        // Registered Callback URLs in TwitterApp
        // Android is a deeplink
        // iOS is a URLScheme
        redirectURI: 'example://',
        // Forces the user to enter their credentials
        // to ensure the correct users account is authorized.
      );

      logger.info(
          'twitterLogin init ${twitterLogin.apiKey.substring(0, 10)} ... ');
      logger.info(
          'twitterLogin init ${twitterLogin.apiSecretKey.substring(0, 10)} ... ');

      final authResult = await twitterLogin.login();
      switch (authResult.status) {
        case TwitterLoginStatus.loggedIn:
          // success
          break;
        case TwitterLoginStatus.cancelledByUser:
          // cancel
          break;
        case TwitterLoginStatus.error:
          // error
          logger.error("TwitterLoginStatus.error: ${authResult.errorMessage}");
          break;
      }

Cancel issue in Android

when I clicked the 'X' in webview, the Future does not end unless I added timeout on it.

final AuthResult authResult = await twitterLogin.login();

PS. It works fine if I click the 'Cancel' button in the twitter login page.

My guess:

https://github.com/0maru/twitter_login/blob/master/lib/src/twitter_login.dart#L71

final browser = ChromeCustomTab(
          onClose: () {
            if (!completer.isCompleted) {
              completer.complete(null);
            }
          },
        );

It looks like the closure onClose() causes the issue. It cannot transfer completer.complete(null); successfully.

Xcode12.5 Crash

I updated from Xcode12.4 to Xcode12.5.
And then I tried to login on twitter.

This is my code.

twitterUser = await _twitterLogin.login();

But the application crashed.

When I use Xcode11.4, the application doesn't crash.

I got following error.
I think it was caused by redirectURI.
But I don't know the solution...

error log
021-04-27 16:10:24.816157+0900 Runner[474:15661] [AuthenticationSession] The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".

2021-04-27 16:10:24.817931+0900 Runner[474:15661] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".'

I use the version 2.1.4.(I am sorry for not using latest version.)

v3.0.4 Android build failing

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:processDebugResources'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
C:\Users\User\AndroidStudioProjects\flutter_app\build\flutter_inappwebview\intermediates\library_manifest\debug\AndroidManifest.xml:7:5-11:15: AAPT: error: unexpected element found in .

The build failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetifier to solve the incompatibility.
Building plugin cloud_firestore...
Exception: The plugin cloud_firestore could not be built due to the issue above.

v3.0.2 dependency issue

Because twitter_login >=3.0.2 depends on crypto ^2.0.0 and my_app depends on crypto ^3.0.0, twitter_login >=3.0.2 is forbidden

crypto ^2.0.0 does not support null-safety

I think it needs to upgrade to crypto ^3.0.0.

Twitterlogout

i am not able to find twitter logout function it will be great if you can add it

No option to retrieve User Id

Hello,

I noticed there is no option to retrieve currently logged in user's id.
It should be 19-digits string.

Am I missing something, or this is not yet implemented?

Thanks!

Cannot work callback url on Android

I build /example, but don't come back to App after authentication in chrome custom tabs on Android.
filled in my URL scheme in AndroidManifest.xml.
anything else needed??

<intent-filter>
 <action android:name="android.intent.action.VIEW" />
 <category android:name="android.intent.category.DEFAULT" />
 <category android:name="android.intent.category.BROWSABLE" />
 <!-- Accepts URIs that begin with "example://gizmos” -->
 <data android:scheme="abcdefg" android:host="" />
</intent-filter>
final twitterLogin = TwitterLogin(
 apiKey: 'xxxxxxxxxxx',
 apiSecretKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    redirectURI: 'abcdefg://',
);

on iOS, it's work well.
Thank you.

Can't login on android device - twitter_login: ^4.0.1

Good evening,
I contact you, because I can't connect to twitter following all the procedures and settings that can be found on the internet and stackoverflow.

Creation of the Twitter developer account : OK
Generation of the API key : OK
Generation of the API secret key : OK
Activation of 3-legged OAuth : is enabled
Added callback URL(s) : DONE

Request email address from users is disabled/enabled => nothing changes

Permission: I tried everything => Read, Write, and Direct Messages

Capture d’écran 2021-12-10 à 23 02 55


Future<UserCredential> signInWithTwitter() async {
    // Create a TwitterLogin instance
    final twitterLogin = TwitterLogin(
        apiKey: 'XXXXXXX',
        apiSecretKey:'YYYYYYYYYYYYYYY',
        redirectURI: 'twitter://'
    );

    // Trigger the sign-in flow
    final authResult = await twitterLogin.login();
    switch (authResult.status!) {
      case TwitterLoginStatus.loggedIn:
        print("SUCCESS");
        break;
      case TwitterLoginStatus.cancelledByUser:
        print("CANCELLED BY USER");
        break;
      case TwitterLoginStatus.error:
        print("ERROR");
        print(authResult.status!.index); // RESULT ==> 2
        print(authResult.status!); // RESULT ==> TwitterLoginStatus.error
        print(authResult.errorMessage); // RESULT ==> Exception: Exception: HttpException: Failed Forbidden
        break;
    }

    // Create a credential from the access token
    final twitterAuthCredential = TwitterAuthProvider.credential(
      accessToken: authResult.authToken!, // This code break but I'm not here
      secret: authResult.authTokenSecret!,
    );

    // Once signed in, return the UserCredential
    return await FirebaseAuth.instance.signInWithCredential(twitterAuthCredential);
  }

------ MANIFEST -------

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

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <!-- Accepts URIs that begin with "example://gizmos” -->
                <!-- Registered Callback URLs in TwitterApp -->
                <data android:scheme="twitter" /> <!-- host is option -->
            </intent-filter>

[✓] Flutter (Channel stable, 2.5.3, on macOS 11.6 20G165 darwin-x64, locale fr-FR)
• Flutter version 2.5.3 at /Users/francoisgaucher/FlutterSDK/202102_flutter/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 18116933e7 (8 weeks ago), 2021-10-15 10:46:35 -0700
• Engine revision d3ea636dc5
• Dart version 2.14.4

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/francoisgaucher/Library/Android/sdk
• Platform android-31, build-tools 30.0.3
• Java binary at: /Applications/Android Studio Preview.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 13.1, Build version 13A1030d
• CocoaPods version 1.10.2

[✓] Android Studio
• Android Studio at /Applications/Android Studio 4.2 Preview.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio Preview.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] Android Studio (version 3.3)
• Android Studio at /Applications/Android Studio 2.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[✓] Android Studio
• Android Studio at /Applications/Android Studio 4.2 Preview 2.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

[✓] Android Studio
• Android Studio at /Users/francoisgaucher/Downloads/Android Studio 4.2 Preview.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Connected device (2 available)
• SM N986B (mobile) • R5CN80J7RDJ • android-arm64 • Android 11 (API 30)
• macOS (desktop) • macos • darwin-x64 • macOS 11.6 20G165 darwin-x64

• No issues found!

Feature request: logout

Seems that this one is missing logout, so user may login with another twitter account, isn't that?

App redirect!

After successfully logging in it does not redirect to app!

Screenshot_1614422888

is this package using UIWebView

After update my app and try upload to Apple store ,
I got this message


ITMS-90809: Deprecated API Usage - New apps that use UIWebView are no longer accepted. Instead, use WKWebView for improved security and reliability. Learn more (https://developer.apple.com/documentation/uikit/uiwebview).

So I want to know if this package still using UIWebView ?

twitter api ver1.1 403 forbidden

Probably, API ver1.1 is not available when creating a new account in twitter developer from November 15, 2021.
Therefore, if you run getUserData(httpGet(ACCOUNT_VERIFY_URI,...)) will result in a 403 error.
You can use API version 1.1 by upgrading your account, but it would be great if you could add the process for API version 2.0!

scheme is not valid.

always show up this warning in debug console,

[AuthenticationSession] Error: The provided scheme is not valid. A scheme must not include any special characters, such as ":" or "/"

and the auth process complete success, and I check the scheme url in info.plist it's without any / or : what is wrong

[CLOSE] I fixed it was my mistake :)

Hello, I tried your package but I couldn't open the login activity. I think it's opening on a webview. But my app always return "Failed Authorization Required" error. What do you think? And also I don't understan the redirectURI field. Thank you :)

issue related with other depended package

I have noticed a lot of crashes happened with my users with a package I have never used so searching and found your package I only used depended on this package that called "pichillilorenzo/flutter_inappwebview"

the crash error is

ChromeCustomTabsActivity.java line 42
com.pichillilorenzo.flutter_inappwebview.chrome_custom_tabs.ChromeCustomTabsActivity.onCreate

Screen Shot 2021-05-16 at 7 53 08 PM

this is a issue topic about this issue
pichillilorenzo/flutter_inappwebview#665

so please investigation more about that issue

Auth redirect on Android failing

I'm implementing this plugin in my app and it works perfectly for iOS.
On Android however, it does not work for some reason.
After successful login, I am stuck on the redirect screen and it does not return back to my app.

Screenshot: drive

Any idea on what's going wrong?

AndroidManifest.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="twittersdk"/>
</intent-filter>

Dart code

String consumerKey = '<--consumer key-->';
String consumerSecret = '<--consumer secret-->';
String redirectURI = 'twittersdk://';

final TwitterLogin twitterLogin = TwitterLogin(
  apiKey: consumerKey,
  apiSecretKey: consumerSecret,
  redirectURI: redirectURI,
);

final AuthResult authResult = await twitterLogin.login();
switch (authResult.status) {
  case TwitterLoginStatus.loggedIn:
    // success
    final AuthCredential credential = TwitterAuthProvider.credential(
     accessToken: authResult.authToken ?? '',
     secret: authResult.authTokenSecret ?? '',
    );
    firebaseUser = (await _auth.signInWithCredential(credential)).user;
    break;
  case TwitterLoginStatus.cancelledByUser:
  // cancel
  return null;
  case TwitterLoginStatus.error:
  // error
  return null;
  default:
  return null;
}

twitter_login bug

I've been using flutter_twitter_login so far. But now the support has been suspended, so I used Twitter_login for the first time. Strangely, however, after logging in, it is redirected to the app and running a new process instead of printing the results. So when you log in to Twitter several times, several main threads are created. What's the matter? I'm running on Android now. So I tested Twitter_login's sample code, but it was the same. why? Help me, please.
Untitled
Untitled
Untitled

Can anyone help me pls?

I am trying to redirect to my app after login complete. But unable to do that , it's showing 404 page after login & can't get the my twitter profile info like name, email etc. it showing this page and not navigating my app WelcomeScreen https://imgur.com/XdW82TU

Callback url set to twitter dev account: https://imgur.com/xOsEqOs

Android manifest:

 <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <!-- Accepts URIs that begin with "example://gizmos” -->
            <!-- Registered Callback URLs in TwitterApp -->
            <data android:scheme="twittersdk://"
                android:host="gizmos" /> <!-- host is option -->
        </intent-filter>

Source Code:
static Future signInWithTwitter(
{BuildContext? context}) async {
String? newMessage;

// Trigger the sign-in flow

final authResult = await twitterLogin.login();

// Create a credential from the access token
final twitterAuthCredential = TwitterAuthProvider.credential(
  accessToken: authResult.authToken.toString(),
  secret: authResult.authTokenSecret.toString(),
);

print(twitterAuthCredential!.providerId);

// Once signed in, return the UserCredential
UserCredential userCredential =
    await FirebaseAuth.instance.signInWithCredential(twitterAuthCredential);

log('your message here');
log('userCredential.user');
log(userCredential.user.toString());
User? user = userCredential.user;
DocumentSnapshot? doc = await Globals.userRef.doc(user!.uid).get();
if (!doc.exists) {
  Globals.userRef.doc(user!.uid).set({
    'uid': user!.uid,
    'email': user.email,
    'firstName': "firstName",
    'lastName': "lastName",
    'displayName': user!.displayName,
    'password': 'hashedPassword',
    'userName': user.email,
    'bio': Globals.loremText,
    'photoUrl': user!.photoURL,
    'phoneNumber': "phoneNumber",
    'userType': "Facebook",
    'publicUrl': "url",
    "isAdmin": false,
    'createdAt': FieldValue.serverTimestamp(),
    'updatedAt': FieldValue.serverTimestamp(),
    'lastLoggedIn': FieldValue.serverTimestamp(),
  });

  switch (authResult.status) {
    case TwitterLoginStatus.loggedIn:
      newMessage = 'User ${user.email} LoggedIn Successfully!';
      ScaffoldMessenger.of(context!).showSnackBar(
        Globals.customSnackBar(
          content: newMessage,
        ),
      );
      break;
    case TwitterLoginStatus.cancelledByUser:
      newMessage = 'Login cancelled by user.';
      ScaffoldMessenger.of(context!).showSnackBar(
        Globals.customSnackBar(
          content: newMessage,
        ),
      );
      break;
    case TwitterLoginStatus.error:
      newMessage = 'Login error: ${authResult.errorMessage}';
      ScaffoldMessenger.of(context!).showSnackBar(
        Globals.customSnackBar(
          content: newMessage,
        ),
      );
      break;
  }
}
Navigator.push(
    context!,
    MaterialPageRoute(
        builder: (context) => WelcomeScreen(
              user: user,
            )));
return userCredential;

}

How I can logout ?

I am confused about log out ? Which class has the method of logout from twitter authentication ?

iOS Configuration issue

Hello
I set it up on Android but It doesn't redirect to my app on iOS
I put this into my info.plist

<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLName</key>
    <string></string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>https://xxx.page.link/xxx</string>
    </array>
  </dict>
</array>

Please help me.

Exception: Exception: HttpException: Failed Forbidden

I am getting these exception even if I turn on api v2 in the developer console
Also I noticed one thing in your example that you are using loginv2 in main.dart in your example but I did not found this method in my example please help me where can I find that method

Only works with Chrome browser on Android device

For other social media plugins, the <intent> is usually registered with a callback Activity from the plugin. But yours requires it to be registered with the MainActivity.

It seems to work on Android simulator but doesn't on real Android device. The problem is I think its conflicting with my app's Deep Linking.

Can you make it so the callback is registered in your own plugin intent?

Blurry thumbnail image

After reading the twitter api docs and learning this package, I realized that this package doesn't provide multiple profile photo size. But since the only difference in normal (48x48) and the original large image is the word "_normal" in file name.

I am using replace function to get large image

String? url = authResult.user?.thumbnailImage.replaceFirst('_normal', '');

Will you modify the code so that developer can get different thumbnail sizes?

[urlScheme] iOS14 - Not routed back to application

Hi,

I can't make it work on iOS 14. Spent literally hours, trying different combination for the urlScheme with no success.
After the login, the URLScheme don't come back to application and result in user cancel.

https://developer.twitter.com/ :
image

image

<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLName</key>
    <string>app.flutter.twitter.login.schemes</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>easivio</string>
    </array>
  </dict>
</array>

image

Please help,
Regards

【iOS】Unable to process request

I encountered a problem that when running on iOS, after logging in to Twitter, the message of the attached image was displayed and the transition to the app did not occur.

Since I received a login notification from Twitter, so I think the login itself works.
Do you have any idea to solve this problem?

Simulator Screen Shot - iPhone 12 Pro Max - 2021-01-31 at 21 43 41

Login on Android hangs with "Redirecting back to the application"

I'm having a problem signing into Android. After displaying the authentication dialog and clicking the Authorize button, the "Redirecting you back to the application" screen is displayed. The circular indicator spins forever and never redirects my back to my application.

My same code is working good on iOS.

This seems similar to issue #69 , however the Developer account has been created for a number of months, and also I have tried both login and loginV2 functions on both versions 4.0.1 and 4.1.0-dev, with the same results.

Both OAuth 1 and OAuth 2 have been enabled.
The redirects on in Twitter are set to leofinance:// and leomobile://.
In my app/src/main/AndroidManifest.xml, I have:

<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />            
<intent-filter android:autoVerify="true">
   <action android:name="android.intent.action.VIEW" />
   <category android:name="android.intent.category.DEFAULT" />
   <category android:name="android.intent.category.BROWSABLE" />
   <data android:scheme="http" android:host="leofinance.io" />
   <data android:scheme="https" />
   <data android:scheme="leofinance" />
</intent-filter>

shawn@MacBook-Pro ~ % flutter doctor -v
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-arm, locale en-US)
• Flutter version 2.8.1 at /Users/shawn/Development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (4 days ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/shawn/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Users/shawn/Downloads/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
• Android Studio at /Users/shawn/Downloads/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] VS Code (version 1.62.3)
• VS Code at /Users/shawn/Downloads/Visual Studio Code.app/Contents
• Flutter extension version 3.29.0

[✓] Connected device (3 available)
• SM A025F (mobile) • R9PR604VDCF • android-arm • Android 11 (API 30)
• Shawn’s iPhone (mobile) • 2e950c689065bc8c3604deb71d053816d35793ba • ios • iOS 14.8.1 18H107
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.110

• No issues found!

cannot configure the iOS project

Hi,
i tried multiple times to configure the iOS project
via using URL Scheme and the app still crashes
ios version : 14.5 / 12.3
flutter : 1.22.6
twitter package : 2.1.4
'NSInvalidArgumentException', reason: 'The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".'

Blank white screen

Am using firebase Auth along with this package. I got a blank screen and no error to help me understand the problem. I am testing on an android 10 device.
This happened when I call the TwitterLogin.login function, which then took me to a blank screen.
I would like to point out that I parsed the API keys and used the same call-back URL for the Twitter console, the XML file, and the dart file.

twitter wahala

Am running on dart version ">=2.15.0-268.18.beta <3.0.0"
and flutter version 2.8.0-3.3.pre

The request token for this page is invalid. Using flutter and firebase

Hello, I can't login with twitter.
I am using Flutter and Firebase, firebase has the right OAuth 1.0a keys, same in my TwitterLogin method, also the intent is correctly written passing the :// format, enabled on authorized redirect on twitter dev.
What is happening? The error I am receiving is "AppAuth: No stored state - unable to handle response".

Error in login: 400, Failed to generate request token., Please check your APIKey or APISecret.

I'm failing attempting to login. I have confirmed that the api key and secret are correct by using twurl which does successfully log me in.

Failure is PlatformException(400, Failed to generate request token., Please check your APIKey or APISecret., null)

Code is simple:

final twitterLogin = TwitterLogin(
          apiKey: 'QW..Zt',
          apiSecretKey: 'pP..8h',
          redirectURI: 'leofinance://');

final authResult = await twitterLogin.login();

Authentication settings in Twitter dev console:
image

This is happening on a real iOS device, twitter_login: ^4.0.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.