flutter_twitter_login
flutter_twitter_login copied to clipboard
Example returns error
Hi.
I cloned the example, changed nothing and ran it on genymotion. When tapping on "Log in" it opens the web browser and then goes back to the app with an error:
"Failed to get request token".
I have tried this with my twitter credentials as well, same error.
I also tried your plugin with Firebase & Flutter, and I got an error saying that no callback url was specified.
I know that with my React Native apps, I needed to specify a callback URL (using Firebase) on Twitter and then also update my android AndroidManifest.xml to support it.
So I am not sure if that's the case here or not?
@roughike
This seems to only happen when the device doesn't have the twitter app installed on it. If possible I would still like to solve this for users who would like to sign up using twitter although (for some odd reason they don't have twitter on their phone).
I have also tried un/locking the callback URL on Twitter. It doesn't make a difference unfortunately.
Any advice?
Is the problem only on Android? Could you attach flutter doctor
output so I could try debug this later?
I have only tried it on Android. I will try to make time later to test it on iOS.
Doctor:
[✓] Flutter (Channel beta, v0.4.4, on Mac OS X 10.13.5 17F77, locale en-ZA) • Flutter version 0.4.4 at /Users/user/flutter • Framework revision f9bb4289e9 (6 weeks ago), 2018-05-11 21:44:54 -0700 • Engine revision 06afdfe54e • Dart version 2.0.0-dev.54.0.flutter-46ab040e58
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3) • Android SDK at /Users/user/Library/Android/sdk • Android NDK at /Users/user/Library/Android/sdk/ndk-bundle • Platform android-27, build-tools 27.0.3 • ANDROID_HOME = /Users/user/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08) • All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 9.4) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 9.4, Build version 9F1027a • ios-deploy 1.9.2 • CocoaPods version 1.5.3
[✓] Android Studio (version 3.0) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 23.2.1 • Dart plugin version 171.4424 • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)
[!] VS Code (version 1.24.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Dart Code extension not installed; install from https://marketplace.visualstudio.com/items?itemName=Dart-Code.dart-code
[✓] Connected devices (1 available) • Samsung Galaxy S6, 6 0 0, API 23, 1440x2560 • 192.168.56.101:5555 • android-x86 • Android 6.0 (API 23)
Can confirm this issue, as well. Built and ran the example application, hitting the "Log In" button causes what looks like a WebView to pop up and then disappear, bringing the user back to the app's home screen.
Build warnings:
Initializing gradle...
Note: /Users/alex/Projects/flutter/flutter_twitter_login/android/src/main/java/com/roughike/fluttertwitterlogin/fluttertwitterlogin/TwitterLoginPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Built build/app/outputs/apk/debug/app-debug.apk.
Output from the debugger:
W/ActivityThread( 4102): handleWindowVisibility: no activity for token android.os.BinderProxy@6ac4c1b
D/EGL_emulation( 4102): eglMakeCurrent: 0xdbf6b2a0: ver 3 0 (tinfo 0xdbfd5f00)
E/Twitter ( 4102): Invalid json: <?xml version="1.0" encoding="UTF-8"?><errors><error code="415">Callback URL not approved for this client application. Approved callback URLs can be adjusted in your application settings</error></errors>
E/Twitter ( 4102): com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
E/Twitter ( 4102): at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:224)
E/Twitter ( 4102): at com.twitter.sdk.android.core.models.SafeListAdapter$1.read(SafeListAdapter.java:45)
E/Twitter ( 4102): at com.twitter.sdk.android.core.models.SafeMapAdapter$1.read(SafeMapAdapter.java:45)
E/Twitter ( 4102): at com.google.gson.Gson.fromJson(Gson.java:887)
E/Twitter ( 4102): at com.google.gson.Gson.fromJson(Gson.java:852)
E/Twitter ( 4102): at com.google.gson.Gson.fromJson(Gson.java:801)
E/Twitter ( 4102): at com.google.gson.Gson.fromJson(Gson.java:773)
E/Twitter ( 4102): at com.twitter.sdk.android.core.TwitterApiException.parseApiError(TwitterApiException.java:110)
E/Twitter ( 4102): at com.twitter.sdk.android.core.TwitterApiException.readApiError(TwitterApiException.java:95)
E/Twitter ( 4102): at com.twitter.sdk.android.core.TwitterApiException.<init>(TwitterApiException.java:43)
E/Twitter ( 4102): at com.twitter.sdk.android.core.Callback.onResponse(Callback.java:42)
E/Twitter ( 4102): at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:68)
E/Twitter ( 4102): at android.os.Handler.handleCallback(Handler.java:873)
E/Twitter ( 4102): at android.os.Handler.dispatchMessage(Handler.java:99)
E/Twitter ( 4102): at android.os.Looper.loop(Looper.java:193)
E/Twitter ( 4102): at android.app.ActivityThread.main(ActivityThread.java:6669)
E/Twitter ( 4102): at java.lang.reflect.Method.invoke(Native Method)
E/Twitter ( 4102): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/Twitter ( 4102): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/Twitter ( 4102): Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
E/Twitter ( 4102): at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385)
E/Twitter ( 4102): at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:213)
E/Twitter ( 4102): ... 18 more
E/Twitter ( 4102): Failed to get request token
E/Twitter ( 4102): com.twitter.sdk.android.core.TwitterApiException: HTTP request failed, Status: 403
E/Twitter ( 4102): at com.twitter.sdk.android.core.Callback.onResponse(Callback.java:42)
E/Twitter ( 4102): at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:68)
E/Twitter ( 4102): at android.os.Handler.handleCallback(Handler.java:873)
E/Twitter ( 4102): at android.os.Handler.dispatchMessage(Handler.java:99)
E/Twitter ( 4102): at android.os.Looper.loop(Looper.java:193)
E/Twitter ( 4102): at android.app.ActivityThread.main(ActivityThread.java:6669)
E/Twitter ( 4102): at java.lang.reflect.Method.invoke(Native Method)
E/Twitter ( 4102): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/Twitter ( 4102): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/Twitter ( 4102): Authorization completed with an error
E/Twitter ( 4102): com.twitter.sdk.android.core.TwitterAuthException: Failed to get request token
E/Twitter ( 4102): at com.twitter.sdk.android.core.identity.OAuthController$1.failure(OAuthController.java:94)
E/Twitter ( 4102): at com.twitter.sdk.android.core.internal.oauth.OAuth1aService$1.failure(OAuth1aService.java:191)
E/Twitter ( 4102): at com.twitter.sdk.android.core.Callback.onResponse(Callback.java:42)
E/Twitter ( 4102): at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:68)
E/Twitter ( 4102): at android.os.Handler.handleCallback(Handler.java:873)
E/Twitter ( 4102): at android.os.Handler.dispatchMessage(Handler.java:99)
E/Twitter ( 4102): at android.os.Looper.loop(Looper.java:193)
E/Twitter ( 4102): at android.app.ActivityThread.main(ActivityThread.java:6669)
E/Twitter ( 4102): at java.lang.reflect.Method.invoke(Native Method)
E/Twitter ( 4102): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/Twitter ( 4102): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/FlutterActivityDelegate( 4102): onResume setting current activity to this
D/EGL_emulation( 4102): eglMakeCurrent: 0xdbf6b2a0: ver 3 0 (tinfo 0xdbfd5f00)
Flutter doctor:
$ flutter doctor -v
[✓] Flutter (Channel beta, v0.5.1, on Mac OS X 10.13.5 17F77, locale en-US)
• Flutter version 0.5.1 at /Volumes/New/flutter
• Framework revision c7ea3ca377 (6 weeks ago), 2018-05-29 21:07:33 +0200
• Engine revision 1ed25ca7b7
• Dart version 2.0.0-dev.58.0.flutter-f981f09760
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at /Users/alex/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.4.1, Build version 9F2000
• ios-deploy 1.9.2
• CocoaPods version 1.5.3
[✓] Android Studio (version 3.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 26.0.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
[!] VS Code (version 1.25.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected devices (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
edit: Can also confirm that this will work on a physical device if the user has Twitter installed and is logged in.
@roughike have you been able to spend time on this issue? Tx
@roughike do you plan to fix this issue? It's really annoying to have such issue where user can't use twitter account if the app is not installed.
I believe that this problem is realted to some changes made on the Twitter side and is not caused by this library. Read: https://twittercommunity.com/t/callback-url-not-approved-but-worked-for-months/107261 And: https://developer.twitter.com/en/docs/basics/developer-portal/guides/callback-urls.html
in short (for Android): Add "twittersdk://" to your Callback URLs inside the Settings Tab of your Twitter Application at apps.twitter.com
Adding "twittersdk://" as a callback url worked for me. Thanks @KammererTob . I can run an emulator and use this plugin well.
@Fallenstedt can you guide me exactly were to add "twittersdk://". I'm using firebase authentication with Twitter.
@surveshoeb You can add twittersdk://
to your callback urls in your application. Navigate to https://developer.twitter.com/en/apps to find your applications.

@Fallenstedt Thanks, it worked.
I've the same error but I have already added twittersdk:// in callback URLs.
The error: Authorize failed come sometimes...
Twitter seems to have changed its developer portal. I was unable to find a way to add callback URLs. Can someone please tell me where I can find it?
Twitter seems to have changed its developer portal. I was unable to find a way to add callback URLs. Can someone please tell me where I can find it?
@skpatrat Open https://developer.twitter.com/en/portal/apps/ and select your App and navigate to bottom of the page to Authentication settings.

@surveshoeb Thanks. Got it :)
adding "twittersdk://" solved my problem aslo thank you all