darwin-morocho / flutter-facebook-auth

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

For some reason asking for OpenId permissions on login #319

Closed LabanauskasTomas closed 1 year ago

LabanauskasTomas commented 1 year ago

What version are you using?

5.0.7

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

macOS 13.0.1

What platforms are you seeing the problem on?

iOS

pubspec.yaml

name: fortune_me
description: A new Flutter project.

# 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.4 <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.5
  firebase_auth: ^4.1.2
  firebase_core: ^2.2.0
  video_player: ^2.4.7 
  cloud_firestore: ^4.0.5
  google_sign_in: ^5.4.2
  flutter_facebook_auth: ^5.0.7

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:
    - assets/beach.mp4
    - assets/moto.mp4
    - assets/Images/
    - assets/Images/Apple_logo.png
    - assets/Images/Facebook_logo.png
    - assets/Images/FortuneMe_logo.png
    - assets/Images/Google_logo.png
  # 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

I get error from Facebook "Invalid scopes: OpenId, Email, Public_Profile..." Without changing the default permissions.

Expected Behavior

It should just work with login

To Reproduce

Installed it on a new project, added to firebase, did everything according to the tutorial

Relevant log output

No response

flutter doctor -v

[✓] Flutter (Channel stable, 3.3.10, on macOS 13.0.1 22A400 darwin-arm, locale en-GB)
    • Flutter version 3.3.10 on channel stable at /Users/Tomas/Downloads/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 135454af32 (2 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 /Users/Tomas/Library/Android/sdk
    • Platform android-33, build-tools 33.0.1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.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.13+0-b1751.21-8125866)

[✓] IntelliJ IDEA Community Edition (version 2022.3.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 71.2.6
    • Dart plugin version 223.8214.16

[✓] VS Code (version 1.73.1)
    • VS Code at /Users/Tomas/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.52.0

[✓] Connected device (3 available)
    • iPhone 14 Pro Max (mobile) • 1425C554-7A64-4978-A555-AA91F0ED9DBB • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-2
      (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS 13.0.1 22A400 darwin-arm
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 108.0.5359.124

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

• No issues found!

Info.plist (iOS)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb644585954110213</string>
                <string>com.googleusercontent.apps.177389765490-210psq3627hro716mfq8hnqi9uo6kclo</string>
            </array>
        </dict>
    </array>
    <key>FacebookAppID</key>
    <string>644585954110213</string>
    <key>FacebookClientToken</key>
    <string>e4099696a1b1679684319b0213335b6c</string>
    <key>FacebookDisplayName</key>
    <string>Fortune Me</string>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleDisplayName</key>
    <string>Fortune Me</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>fortune_me</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(FLUTTER_BUILD_NAME)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
    <key>CADisableMinimumFrameDurationOnPhone</key>
    <true/>
    <key>UIApplicationSupportsIndirectInputEvents</key>
    <true/>
</dict>
</plist>

Podfile (iOS)

# Uncomment this line to define a global platform for your project
platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

AndroidManifest.xml

No response

MainActivity.java

No response

MainActivity.kt

No response

index.html

No response

Info.plist (macOS)

No response

LabanauskasTomas commented 1 year ago
    // Trigger the sign-in flow
    final LoginResult loginResult = await FacebookAuth.instance.login();

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

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

The code I'm using for sign in.

And this is what I get after enetering facebook credentials

Simulator-Screen-Shot-i-Phone-14-Pro-Max-2023-01-01-at-16-46-54

darwin-morocho commented 1 year ago

@LabanauskasTomas sorry but I am not able to help you. Because this is not an issue of this plugin.

darwin-morocho commented 1 year ago

@LabanauskasTomas sorry but I am not able to help you. Because this is not an issue of this plugin.

Please go to the official Facebook documentation and check what are the requirements to use that permissions

LabanauskasTomas commented 1 year ago

Well I override permissions

Future<UserCredential> signInWithFacebook() async {
    // Trigger the sign-in flow
    final LoginResult loginResult = await FacebookAuth.instance.login(permissions: ['email']);

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

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

but still this plugin adds OpenId to the request.

The problem is only with OpenId scope added by this plugin.

darwin-morocho commented 1 year ago

Well I override permissions

Future<UserCredential> signInWithFacebook() async {
    // Trigger the sign-in flow
    final LoginResult loginResult = await FacebookAuth.instance.login(permissions: ['email']);

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

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

but still this plugin adds OpenId to the request.

The problem is only with OpenId scope added by this plugin.

In your info.plist I cannot see this tags


<key>FacebookDisplayName</key>
<string>{your-app-name}</string>
<key>LSApplicationQueriesSchemes</key>
<array>
  <string>fbapi</string>
  <string>fb-messenger-share-api</string>
</array>
darwin-morocho commented 1 year ago

By default this plugin uses only the next scopes public_profile and email. If the problem persists Try using the version 4.x.x

shafeekghaseel commented 1 year ago

Fixed issue?, I'm also facing this same issue.

ncr9108 commented 1 year ago

I am facing Same issue.

LabanauskasTomas commented 1 year ago

Yes, I did eventually find what was causing the problem.

According to Facebook this message or error shows up when you're trying to use Facebook Application that doesn't have full information. Basically just as your own Privacy Policy, fill in the form about the application and you'll be good to go :) This change is from 2023-01-01 according to their new policy, so that's why in all of the tutorials there's no info about it.

ncr9108 commented 1 year ago

Yes, I did eventually find what was causing the problem.

According to Facebook this message or error shows up when you're trying to use Facebook Application that doesn't have full information. Basically just as your own Privacy Policy, fill in the form about the application and you'll be good to go :) This change is from 2023-01-01 according to their new policy, so that's why in all of the tutorials there's no info about it.

But i added all basic information although it's showing same error. can you explain more. Which info is required.

LabanauskasTomas commented 1 year ago

Yes, I did eventually find what was causing the problem. According to Facebook this message or error shows up when you're trying to use Facebook Application that doesn't have full information. Basically just as your own Privacy Policy, fill in the form about the application and you'll be good to go :) This change is from 2023-01-01 according to their new policy, so that's why in all of the tutorials there's no info about it.

But i added all basic information although it's showing same error. can you explain more. Which info is required.

I can't. I ended up using other application on Facebook. If you're experiencing issues contact Facebook Developer support.

As far as this package goes, it works as it should.

LabanauskasTomas commented 1 year ago

I found out that you have to have verified business for facebook login to work :)