darwin-morocho / flutter-facebook-auth

A flutter plugin to add login with facebook in your flutter app
193 stars 127 forks source link

Login failed #52

Closed bereznic closed 3 years ago

bereznic commented 3 years ago

Describe the bug I've followed every step from the docs, and i got to the point where triggering the facebook login event pops the facebook account selector. But after choosing the account and pressing login, my flutter app gives login failed (error: FacebookAuthErrorCode.FAILED)

Environment Flutter doctor: [√] Flutter (Channel dev, 1.27.0-1.0.pre, on Microsoft Windows [Version 10.0.19041.804], locale en-US) • Flutter version 1.27.0-1.0.pre at D:\flutter • Framework revision 68c96f100e (10 days ago), 2021-02-08 16:14:15 -0800 • Engine revision b04955656c • Dart version 2.13.0 (build 2.13.0-0.0.dev)

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at C:\Users\dani\AppData\Local\Android\Sdk • Platform android-29, build-tools 29.0.2 • Java binary at: C:\Program Files\Java\jdk1.8.0_202\bin\java • Java version Java(TM) SE Runtime Environment (build 1.8.0_202-b08) • All Android licenses accepted.

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

[√] Android Studio (version 4.1.0) • Android Studio at D:\AndroidStudio • 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-b01)

[!] Android Studio • Android Studio at D:\AndroidStudio\bin • 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 X android-studio-dir = D:\AndroidStudio\bin X Unable to find bundled Java version. • Try updating or re-installing Android Studio. • Consider removing your android-studio-dir setting by running: flutter config --android-studio-dir=

[√] IntelliJ IDEA Community Edition (version 2020.2) • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.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 (3 available) • SM A505FN (mobile) • R58M73TGJWT • android-arm64 • Android 10 (API 29) • Chrome (web) • chrome • web-javascript • Google Chrome 88.0.4324.150 • Edge (web) • edge • web-javascript • Microsoft Edge 88.0.705.68

! Doctor found issues in 1 category.

Pubspec.yaml: name: fitter_fit_2 description: A new Flutter project. publish_to: 'none' version: 1.27.0-1.0.pre

environment: sdk: ">=2.7.0 <3.0.0"

dependencies: flutter: sdk: flutter provider: ^4.3.2+3 firebase_core: ^0.8.0-1.0.nullsafety.0 firebase_auth: ^0.21.0-1.1.nullsafety.1 cloud_firestore: ^0.17.0-1.0.nullsafety.0 google_sign_in: ^5.0.0-nullsafety flutter_facebook_auth: ^2.0.2 regexpattern: ^1.0.0

flushbar: ^1.10.4

tuple: ^2.0.0-nullsafety.0 flutter_svg: ^0.20.0-nullsafety.3 font_awesome_flutter: ^9.0.0-nullsafety

. cupertino_icons: ^1.0.0

dev_dependencies: flutter_test: sdk: flutter

flutter:

uses-material-design: true

assets:

AndroidManifest.xml: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.fitter_fit_2">

<uses-permission android:name="android.permission.INTERNET" />

<application
    android:name="io.flutter.app.FlutterApplication"
    android:label="@string/app_name"
    android:icon="@mipmap/ic_launcher">

    <meta-data 
      android:name="com.facebook.sdk.ApplicationId"
      android:value="@string/facebook_app_id"/>
    <activity 
      android:name="com.facebook.FacebookActivity"
      android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
      android:label="@string/app_name" />
    <activity
      android:name="com.facebook.CustomTabActivity"
      android:exported="true">
      <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="@string/fb_login_protocol_scheme" />
      </intent-filter>
    </activity>

    <activity
        android:name=".MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize">
        <meta-data
          android:name="io.flutter.embedding.android.NormalTheme"
          android:resource="@style/NormalTheme"
          />
        <meta-data
          android:name="io.flutter.embedding.android.SplashScreenDrawable"
          android:resource="@drawable/launch_background"
          />
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <meta-data
        android:name="flutterEmbedding"
        android:value="2" />
</application>

strings.xml: <?xml version="1.0" encoding="utf-8"?>

FitterFit2 ########## fb########

To Reproduce Please add your code to reproduce the issue

Expected behavior A clear and concise description of what you expected to happen.

Video

the user that i'm using in the video is a Test user generated with facebook developers site, the app is in development mode, it's not published yet

https://user-images.githubusercontent.com/48672840/108399304-a2c1da80-7222-11eb-8493-2155c80849c2.mp4

darwin-morocho commented 3 years ago

hi @bereznic can you run the Android project using Android studio Android check the logcat?

When you have this behavior maybe your Android configuration in your facebook developer console is wrong

bereznic commented 3 years ago

I/ViewRootImpl@157ffc8MainActivity: ViewPostIme pointer 0 I/ViewRootImpl@157ffc8MainActivity: ViewPostIme pointer 1 I/behavior::(29137): DIALOG_ONLY W/ActivityThread(29137): handleWindowVisibility: no activity for token android.os.BinderProxy@1df9d1 D/PhoneWindow(29137): forceLight changed to true [] from com.android.internal.policy.PhoneWindow.updateForceLightNavigationBar:4274 com.android.internal.policy.DecorView.updateColorViews:1547 com.android.internal.policy.PhoneWindow.dispatchWindowAttributesChanged:3252 android.view.Window.setFlags:1153 com.android.internal.policy.PhoneWindow.generateLayout:2474 I/MultiWindowDecorSupport(29137): [INFO] isPopOver = false I/MultiWindowDecorSupport(29137): updateCaptionType >> DecorView@47be62f[], isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true D/MultiWindowDecorSupport(29137): setCaptionType = 0, DecorView = DecorView@47be62f[] I/ViewRootImpl@aca5f91FacebookActivity: setView = com.android.internal.policy.DecorView@47be62f TM=true MM=false I/ViewRootImpl@aca5f91FacebookActivity: Relayout returned: old=(0,0,1080,2340) new=(0,0,1080,2340) req=(1080,2340)0 dur=8 res=0x7 s={true 503237816320} ch=true D/OpenGLRenderer(29137): createReliableSurface : 0x75c68e0a80(0x752b4fb000) I/mali_winsys(29137): new_window_surface() [1080x2340] return: 0x3000 D/OpenGLRenderer(29137): eglCreateWindowSurface : 0x752d28fa00 D/OpenGLRenderer(29137): makeCurrent EglSurface : 0x752c864a00 -> 0x752d28fa00 I/ViewRootImpl@157ffc8MainActivity: MSG_WINDOW_FOCUS_CHANGED 0 1 D/InputMethodManager(29137): prepareNavigationBarInfo() DecorView@737aa7b[MainActivity] D/InputMethodManager(29137): getNavigationBarColor() -855310 I/ViewRootImpl@aca5f91FacebookActivity: MSG_WINDOW_FOCUS_CHANGED 1 1 D/InputMethodManager(29137): prepareNavigationBarInfo() DecorView@47be62f[FacebookActivity] D/InputMethodManager(29137): getNavigationBarColor() -855310 D/InputMethodManager(29137): prepareNavigationBarInfo() DecorView@47be62f[FacebookActivity] D/InputMethodManager(29137): getNavigationBarColor() -855310 V/InputMethodManager(29137): Starting input: tba=com.example.fitter_fit_2 ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false D/InputMethodManager(29137): startInputInner - Id : 0 I/InputMethodManager(29137): startInputInner - mService.startInputOrWindowGainedFocus I/ViewRootImpl@aca5f91FacebookActivity: MSG_RESIZED: frame=(0,0,1080,2340) ci=(0,83,0,126) vi=(0,83,0,126) or=1 I/ViewRootImpl@aca5f91FacebookActivity: MSG_WINDOW_FOCUS_CHANGED 0 1 D/InputMethodManager(29137): prepareNavigationBarInfo() DecorView@47be62f[FacebookActivity] D/InputMethodManager(29137): getNavigationBarColor() -855310 D/OpenGLRenderer(29137): makeCurrent EglSurface : 0x752d28fa00 -> 0x0 D/OpenGLRenderer(29137): destroyEglSurface : 0x752d28fa00 I/mali_egl(29137): eglDestroySurface() in I/mali_winsys(29137): delete_surface() [1080x2340] return I/mali_egl(29137): eglDestroySurface() out E/OpenGLRenderer(29137): ReliableSurface: perform returned an error W/libEGL (29137): EGLNativeWindowType 0x75c68e0a90 disconnect failed D/OpenGLRenderer(29137): ~ReliableSurface : 0x75c68e0a80 I/ViewRootImpl@aca5f91FacebookActivity: Relayout returned: old=(0,0,1080,2340) new=(0,0,1080,2340) req=(1080,2340)8 dur=6 res=0x5 s={false 0} ch=true D/InputTransport(29137): Input channel destroyed: 'ClientS', fd=96 I/ViewRootImpl@aca5f91FacebookActivity: stopped(true) old=false I/SurfaceView(29137): onWindowVisibilityChanged(8) false io.flutter.embedding.android.FlutterSurfaceView{191d6a V.E...... ........ 0,0-1080,2214} of ViewRootImpl@157ffc8[MainActivity] I/SurfaceView(29137): surfaceDestroyed callback.size 1 #2 io.flutter.embedding.android.FlutterSurfaceView{191d6a V.E...... ........ 0,0-1080,2214} I/mali_egl(29137): eglDestroySurface() in I/mali_winsys(29137): delete_surface() [1080x2214] return I/mali_egl(29137): eglDestroySurface() out W/libEGL (29137): EGLNativeWindowType 0x752b4c4010 disconnect failed I/SurfaceView(29137): remove() io.flutter.embedding.android.FlutterSurfaceView{191d6a V.E...... ........ 0,0-1080,2214} Surface(name=SurfaceView - com.example.fitter_fit_2/com.example.fitter_fit_2.MainActivity@191d6a@4)/@0xaa3ccad D/OpenGLRenderer(29137): destroyEglSurface : 0x752c864a00 I/mali_egl(29137): eglDestroySurface() in I/mali_winsys(29137): delete_surface() [1080x2340] return I/mali_egl(29137): eglDestroySurface() out E/OpenGLRenderer(29137): ReliableSurface: perform returned an error W/libEGL (29137): EGLNativeWindowType 0x75c68e29d0 disconnect failed D/OpenGLRenderer(29137): ~ReliableSurface : 0x75c68e29c0 I/ViewRootImpl@157ffc8MainActivity: Relayout returned: old=(0,0,1080,2340) new=(0,0,1080,2340) req=(1080,2340)8 dur=14 res=0x5 s={false 0} ch=true I/ViewRootImpl@157ffc8MainActivity: stopped(true) old=false I/SurfaceView(29137): windowStopped(true) false io.flutter.embedding.android.FlutterSurfaceView{191d6a V.E...... ........ 0,0-1080,2214} of ViewRootImpl@157ffc8[MainActivity] I/SurfaceView(29137): onWindowVisibilityChanged(4) false io.flutter.embedding.android.FlutterSurfaceView{191d6a V.E...... ........ 0,0-1080,2214} of ViewRootImpl@157ffc8[MainActivity] I/ViewRootImpl@157ffc8MainActivity: Relayout returned: old=(0,0,1080,2340) new=(0,0,1080,2340) req=(1080,2340)4 dur=13 res=0x1 s={false 0} ch=false I/ViewRootImpl@aca5f91FacebookActivity: stopped(false) old=true I/ViewRootImpl@157ffc8MainActivity: stopped(false) old=true I/SurfaceView(29137): windowStopped(false) false io.flutter.embedding.android.FlutterSurfaceView{191d6a V.E...... ........ 0,0-1080,2214} of ViewRootImpl@157ffc8[MainActivity] I/ViewRootImpl@aca5f91FacebookActivity: Relayout returned: old=(0,0,1080,2340) new=(0,0,1080,2340) req=(1080,2340)0 dur=13 res=0x7 s={true 503234256896} ch=true D/OpenGLRenderer(29137): createReliableSurface : 0x75c68dec80(0x752b196000) D/OpenGLRenderer(29137): makeCurrent EglSurface : 0x0 -> 0x0 I/mali_winsys(29137): new_window_surface() [1080x2340] return: 0x3000 D/OpenGLRenderer(29137): eglCreateWindowSurface : 0x752c864a00 D/OpenGLRenderer(29137): makeCurrent EglSurface : 0x0 -> 0x752c864a00 I/SurfaceView(29137): onWindowVisibilityChanged(0) true io.flutter.embedding.android.FlutterSurfaceView{191d6a V.E...... ........ 0,0-1080,2214} of ViewRootImpl@157ffc8[MainActivity] I/ViewRootImpl@157ffc8MainActivity: Relayout returned: old=(0,0,1080,2340) new=(0,0,1080,2340) req=(1080,2340)0 dur=18 res=0x7 s={true 503237545984} ch=true D/OpenGLRenderer(29137): createReliableSurface : 0x752d3a9140(0x752b4b9000) I/mali_winsys(29137): new_window_surface() [1080x2340] return: 0x3000 D/OpenGLRenderer(29137): eglCreateWindowSurface : 0x752d28fa00 I/SurfaceView(29137): surfaceCreated 1 #8 io.flutter.embedding.android.FlutterSurfaceView{191d6a V.E...... ........ 0,0-1080,2214} I/mali_winsys(29137): new_window_surface() [1080x2214] return: 0x3000 I/SurfaceView(29137): surfaceChanged (1080,2214) 1 #8 io.flutter.embedding.android.FlutterSurfaceView{191d6a V.E...... ........ 0,0-1080,2214} D/OpenGLRenderer(29137): makeCurrent EglSurface : 0x752c864a00 -> 0x752d28fa00 I/OpenGLRenderer(29137): doUpdatePositionAsync is called and callVoidMethod I/System.out(29137): (HTTPLog)-Static: isSBSettingEnabled false I/System.out(29137): (HTTPLog)-Static: isSBSettingEnabled false I/ViewRootImpl@aca5f91FacebookActivity: MSG_WINDOW_FOCUS_CHANGED 1 1 D/InputMethodManager(29137): prepareNavigationBarInfo() DecorView@47be62f[FacebookActivity] D/InputMethodManager(29137): getNavigationBarColor() -855310 D/InputMethodManager(29137): prepareNavigationBarInfo() DecorView@47be62f[FacebookActivity] D/InputMethodManager(29137): getNavigationBarColor() -855310 V/InputMethodManager(29137): Starting input: tba=com.example.fitter_fit_2 ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false D/InputMethodManager(29137): startInputInner - Id : 0 I/InputMethodManager(29137): startInputInner - mService.startInputOrWindowGainedFocus I/ViewRootImpl@157ffc8MainActivity: stopped(false) old=false I/ViewRootImpl@aca5f91FacebookActivity: stopped(true) old=false D/OpenGLRenderer(29137): destroyEglSurface : 0x752c864a00 I/mali_egl(29137): eglDestroySurface() in I/mali_winsys(29137): delete_surface() [1080x2340] return I/mali_egl(29137): eglDestroySurface() out E/OpenGLRenderer(29137): ReliableSurface: perform returned an error W/libEGL (29137): EGLNativeWindowType 0x75c68dec90 disconnect failed D/OpenGLRenderer(29137): ~ReliableSurface : 0x75c68dec80 I/ViewRootImpl@aca5f91FacebookActivity: dispatchDetachedFromWindow D/InputTransport(29137): Input channel destroyed: 'c9c8af ', fd=98 I/ViewRootImpl@157ffc8MainActivity: MSG_WINDOW_FOCUS_CHANGED 1 1 D/InputMethodManager(29137): prepareNavigationBarInfo() DecorView@737aa7b[MainActivity] D/InputMethodManager(29137): getNavigationBarColor() -855310 D/InputMethodManager(29137): prepareNavigationBarInfo() DecorView@737aa7b[MainActivity] D/InputMethodManager(29137): getNavigationBarColor() -855310 V/InputMethodManager(29137): Starting input: tba=com.example.fitter_fit_2 ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false D/InputMethodManager(29137): startInputInner - Id : 0 I/InputMethodManager(29137): startInputInner - mService.startInputOrWindowGainedFocus D/InputTransport(29137): Input channel destroyed: 'ClientS', fd=110 E/ViewRootImpl(29137): sendUserActionEvent() mView returned.

darwin-morocho commented 3 years ago

@bereznic could you try this code

final AccessToken accessToken = await FacebookAuth.instance.login( loginBehavior: LoginBehavior.NATIVE_WITH_FALLBACK, );de

bereznic commented 3 years ago

I've tried it, still doesn't work

darwin-morocho commented 3 years ago

@bereznic could you give me access to your code to check the error

bereznic commented 3 years ago

EDIT: I gave you acces to the whole repo

Future signInWithFacebook() async { print("START LOGIN"); String connection = await checkConnection(); //This is a function that looks up google.com to see if the user is connected to internet if (connection == 'not connected') return 'not connected'; try { // by default the login method has the next permissions ['email','public_profile'] final AccessToken accessToken = await FacebookAuth.instance.login(loginBehavior: LoginBehavior.NATIVE_WITH_FALLBACK); print(accessToken.toJson()); // get the user data final userData = await FacebookAuth.instance.getUserData(); return userData; } on FacebookAuthException catch (e) { switch (e.errorCode) { case FacebookAuthErrorCode.OPERATION_IN_PROGRESS: return "You have a previous login operation in progress"; break; case FacebookAuthErrorCode.CANCELLED: return "login cancelled"; break; case FacebookAuthErrorCode.FAILED: print("SFARSIT"); return "login failed"; break; } } }

darwin-morocho commented 3 years ago

@bereznic the above code is not enough to reproduce the error. I need access to your project. If you can't give me access to your project. Please check your Android configuration in your console.

Also here uou have a valid example https://github.com/meedu-app/flutter-facebook-login-example/tree/firebase_auth change your credentials and run the project and let me known if the error persist

bereznic commented 3 years ago

I gave you access to the repo

darwin-morocho commented 3 years ago

I gave you access to the repo

I've cloned and runned your project without any problem. Please check your credentials in your facebook developer console.

Here you have my environment

[✓] Flutter (Channel beta, 1.26.0-17.3.pre, on macOS 11.1 20C69 darwin-x64,
    locale es-419)
    • Flutter version 1.26.0-17.3.pre at /Users/darwin/development/flutter
    • Framework revision 4b50ca7f7f (2 weeks ago), 2021-02-04 19:44:27 -0800
    • Engine revision 2c527d6c7e
    • Dart version 2.12.0 (build 2.12.0-259.8.beta)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/darwin/Library/Android/sdk
    • Platform android-30, build-tools 29.0.3
    • ANDROID_HOME = /Users/darwin/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_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.2, Build version 12B45b
    • CocoaPods version 1.10.0

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

[✓] 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)

[✓] VS Code (version 1.52.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.19.0

[✓] Connected device (2 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API
      30) (emulator)
    • Chrome (web)            • chrome        • web-javascript • Google Chrome
      86.0.4240.198

• No issues found!

My Facebook developer console (don't use my hash for your console) image

https://user-images.githubusercontent.com/15864336/108570441-e4628c00-72db-11eb-9fbf-2ecfd4ebeadf.mp4

Sorry, I can't help you anymore with this issue because I cannot reproduce it.

Maybe your key hash is invalid. This is a common error on Windows. Please check https://developers.facebook.com/docs/facebook-login/android/advanced?locale=en_US Also you can check how to get a valid key hash for android here (video in Spanish) https://youtu.be/X-x5pHQ4Gz8?t=715 this video uses java. So as your project uses kotlin you can replace your Maincivity.kt for one MainActivity.java

bereznic commented 3 years ago

I've tried with a new project, using java instead of kotlin and now i'm getting this error: "MissingPluginException(No implementation found for method login on channel app.meedu/flutter_facebook_auth)"

darwin-morocho commented 3 years ago

I've tried with a new project, using java instead of kotlin and now i'm getting this error: "MissingPluginException(No implementation found for method login on channel app.meedu/flutter_facebook_auth)"

If you have this error is because you don't have the Android configuration yet

bereznic commented 3 years ago

Ok so i finally made it work. I created a new flutter project without kotlin support, and after completing the configuration steps, everything works fine! Thank you!

Jasics0 commented 3 years ago

Hello, I've a same error. I've tried create a new project without kotlin, but I still get the same error. handleWindowVisibility: no activity for token android.os.BinderProxy@e1e838d Did you some different?

image

bereznic commented 3 years ago

Hello, I've a same error. I've tried create a new project without kotlin, but I still get the same error. handleWindowVisibility: no activity for token android.os.BinderProxy@e1e838d Did you some different?

image

After trying eith java instead of kotlin everything worked just fine. Make sure your facebook configs are on point

darwin-morocho commented 3 years ago

Hello, I've a same error. I've tried create a new project without kotlin, but I still get the same error. handleWindowVisibility: no activity for token android.os.BinderProxy@e1e838d Did you some different?

image

Hi @Jasics0 the only difference is that I'm using macOS

Jasics0 commented 3 years ago

How I can be sure that my facebook configurates are on point?

bereznic commented 3 years ago

How I can be sure that my facebook configurates are on point?

Follow the docs/tutorial xD

neroaCu commented 2 years ago

I found some android devices work and some not. Does anyone have the same issue? I error I got is something like "the has key is different from the one configured already". But I guess it's more likely something else i missing rather than the configuration in facebook developer console. Because this error does not happen all the time.