darwin-morocho / flutter-facebook-auth

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

Login error #322

Closed arisAlexis closed 11 months ago

arisAlexis commented 1 year ago

What version are you using?

5.0.7

What OS and version are you using to local deploy your application?

Windows 11

What platforms are you seeing the problem on?

Android

pubspec.yaml

# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1

environment:
  sdk: '>=2.18.6 <3.0.0'

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  firebase_core: ^2.4.1
  firebase_analytics: ^10.1.0
  firebase_app_check: ^0.1.1+8
  firebase_auth: ^4.2.5
  cloud_firestore: ^4.3.1
  cloud_functions: ^4.0.7
  firebase_storage: ^11.0.10
  flutter_dotenv: ^5.0.2
  shared_preferences: ^2.0.15
  provider: ^6.0.5
  flutter_easyloading: ^3.0.5
  flutter_facebook_auth: ^5.0.7
  flutter_login: ^4.1.1
  rflutter_alert: ^2.0.4

dev_dependencies:
  flutter_test:
    sdk: flutter

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^2.0.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
    - images/fulllogo.png
    - .env
    - .env_prod

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

Describe the Bug

Login error after launching the FB native app. All the configuration seems valid, I have put all the debug and release hashes, I have configured it on FB console, manifest files and on my emulator I am logged in with a test user account from this app because it's not live yet. I have asked permission for email and public profile.

Expected Behavior

login

To Reproduce

final LoginResult loginResult = await FacebookAuth.instance.login();

// Create a credential from the access token
final OAuthCredential facebookAuthCredential =
FacebookAuthProvider.credential(loginResult.accessToken!.token);

Relevant log output

No response

flutter doctor -v

[√] Flutter (Channel stable, 3.3.10, on Microsoft Windows [Version 10.0.22621.963], locale en-US)
    • Flutter version 3.3.10 on channel stable at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 135454af32 (4 weeks ago), 2022-12-15 07:36:55 -0800
    • Engine revision 3316dd8728
    • Dart version 2.18.6
    • DevTools version 2.15.0

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at C:\Users\arisg\AppData\Local\Android\Sdk
    • Platform android-33, build-tools 33.0.1
    • ANDROID_HOME = C:\Users\arisg\AppData\Local\Android\Sdk
    • Java binary at:
      C:\Users\arisg\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\211.7628.21.2111.8092744\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)
    • All Android licenses accepted.

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

[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2022 17.3.5)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools
    • Visual Studio Build Tools 2022 version 17.3.32922.545
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.1)
    • Android Studio at C:\Users\arisg\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\211.7628.21.2111.8092744
    • Flutter plugin version 63.2.1
    • Dart plugin version 203.8452
    • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)

[√] IntelliJ IDEA Community Edition (version 2022.2)
    • IntelliJ at C:\Users\arisg\AppData\Local\JetBrains\Toolbox\apps\IDEA-C\ch-0\222.4459.24
    • Flutter plugin version 71.2.5
    • Dart plugin version 222.4459.16

[√] IntelliJ IDEA Community Edition (version 2022.3)
    • IntelliJ at C:\Users\arisg\AppData\Local\JetBrains\Toolbox\apps\IDEA-C\ch-0\223.8214.52
    • Flutter plugin version 71.3.6
    • Dart plugin version 223.8214.16

[√] VS Code (version 1.74.1)
    • VS Code at C:\Users\arisg\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.54.0

[√] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.22621.963]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 108.0.5359.125
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 107.0.1418.52

[√] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Info.plist (iOS)

No response

Podfile (iOS)

No response

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.jouverse.jouverse"
          xmlns:tools="http://schemas.android.com/tools">
    <queries>
        <provider android:authorities="com.facebook.katana.provider.PlatformProvider" />
    </queries>
   <application
        android:label="jouverse"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            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">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>

        </activity>

<!--       <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>-->

        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
       <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
       <meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>
    </application>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>

</manifest>

MainActivity.java

No response

MainActivity.kt

No response

index.html

No response

Info.plist (macOS)

No response

iamnabink commented 1 year ago

@arisAlexis same issue here, @darwin-morocho any solution yet?

darwin-morocho commented 1 year ago

@arisAlexis @iamnabink the issue must include the android logs to have an idea that what is happenning.

By the way. In Windows the debug key hash generated by using the cmd is not valid.

Check https://developers.facebook.com/docs/facebook-login/android/troubleshooting

Also this issue must be opened in the official Facebook sdk repository https://github.com/facebook/facebook-android-sdk

ngsanti commented 1 year ago

Most likely an issue on the Facebook side. I am also experiencing this issue, was able to login only once (then unable after logging out and in) after reinstalling the Facebook app. Still looking into this, will update when I get more info

UPDATE (6 hours later): now it is working without any problems they must have fixed it

arisAlexis commented 1 year ago

@darwin-morocho how to get the android logs? When the FB app opens and I get the login error there is no flutter error caught because it's outside of my app. I still haven't been able to login correctly. The hashes are correct triple-checked.

In the docs you say "If want to test the login flow with the native facebook app and your app is in developing mode your account must be added to the developer team https://developers.facebook.com/docs/development/build-and-test/app-roles"

I can't add myself as a developer because I am the admin and you can't change roles it gives you an error. I am instead trying to login with a Test User. The app is not live. Do you think that's the problem?

@iamnabink did you solve your problem?

darwin-morocho commented 1 year ago

@darwin-morocho how to get the android logs? When the FB app opens and I get the login error there is no flutter error caught because it's outside of my app. I still haven't been able to login correctly. The hashes are correct triple-checked.

In the docs you say "If want to test the login flow with the native facebook app and your app is in developing mode your account must be added to the developer team https://developers.facebook.com/docs/development/build-and-test/app-roles"

I can't add myself as a developer because I am the admin and you can't change roles it gives you an error. I am instead trying to login with a Test User. The app is not live. Do you think that's the problem?

@iamnabink did you solve your problem?

You must run the android project in android studio and use the LOG CAT to watch the crash errors or any additional errors in your device

arisAlexis commented 11 months ago

had an app revamp and it started working although both times the hashes were correct so i'll close it for now.