darwin-morocho / flutter-facebook-auth

A flutter plugin to add login with facebook in your flutter app
191 stars 124 forks source link

Instance of 'AccessToken' #394

Closed jstdk closed 1 month ago

jstdk commented 1 month ago

What version are you using?

6.1.1

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

Linux Mint 21.3

What platforms are you seeing the problem on?

web

pubspec.yaml

name: bla
description: bla

publish_to: "none" # Remove this line if you wish to publish to pub.dev

version: 1.0.0+1

environment:
    sdk: '>=3.0.2 <4.0.0'
dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  supabase_flutter: ^2.3.4
  local_auth: ^2.2.0
  font_awesome_flutter: ^10.7.0
  responsive_framework: ^1.4.0
  shared_preferences: ^2.2.2
  provider: ^6.1.2
  email_validator: ^2.1.16
  flutter_native_splash: ^2.4.0
  circle_flags: ^4.0.2
  file_picker: ^8.0.0+1
  url_launcher: ^6.2.5
  jiffy: ^6.2.2
  file_saver: ^0.2.12
  flutter_facebook_auth: ^6.1.1
  http: ^1.2.1
  envied: ^0.5.3
  html: ^0.15.4
  flutter_spinkit: ^5.2.1
  badges: ^3.1.2
  uno: ^1.1.9

dependency_overrides:
  intl: 0.19.0

dev_dependencies:
  build_runner: ^2.4.8
  envied_generator: ^0.5.3
  flutter_lints: ^3.0.1
  path_provider: ^2.1.2

flutter:
  uses-material-design: true
  assets:
    - assets/i18n/en.json
    - assets/i18n/nl.json
  fonts:
    - family: OpenSans
      fonts:
        - asset: assets/fonts/OpenSans-Regular.ttf
    - family: OpenSansExtraBold
      fonts:
        - asset: assets/fonts/OpenSans-ExtraBold.ttf

Describe the Bug

On Sunday it worked fine. Without any changes, on Monday I do not receive an access token anymore, only an "Instance of AccessToken"

Expected Behavior

Recieve an access token

To Reproduce

final AccessToken? accessToken = await FacebookAuth.instance.accessToken;
if (accessToken != null) {
  print(accessToken);
} else {
  print("Not logged in");
  final LoginResult result = await FacebookAuth.instance
      .login();
  if (result.status == LoginStatus.success) {
    final AccessToken accessToken = result.accessToken!;
    print(accessToken);
  } else {
    print(result.status);
    print(result.message);
  }
}

Relevant log output

The method FB.getLoginStatus can no longer be called from http pages.
https://developers.facebook.com/blog/post/2018/06/08/enforce-https-facebook-login/
Not logged in
The method FB.login can no longer be called from http pages.
https://developers.facebook.com/blog/post/2018/06/08/enforce-https-facebook-login/
Instance of 'AccessToken'

flutter doctor -v

[✓] Flutter (Channel stable, 3.19.4, on Linux Mint 21.3 6.7.2-060702-generic,
    locale en_US.UTF-8)
    • Flutter version 3.19.4 on channel stable at /home/bla/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 68bfaea224 (5 days ago), 2024-03-20 15:36:31 -0700
    • Engine revision a5c24f538d
    • Dart version 3.3.2
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/bla/Android/Sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /home/bla/Android/Sdk
    • Java binary at: /usr/bin/java
    • Java version OpenJDK Runtime Environment (build 18.0.2-ea+9-Ubuntu-222.04)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /usr/bin/chromium

[✗] Linux toolchain - develop for Linux desktop
    ✗ clang++ is required for Linux development.
      It is likely available from your distribution (e.g.: apt install clang),
      or can be downloaded from https://releases.llvm.org/
    ✗ CMake is required for Linux development.
      It is likely available from your distribution (e.g.: apt install cmake),
      or can be downloaded from https://cmake.org/download/
    ✗ ninja is required for Linux development.
      It is likely available from your distribution (e.g.: apt install
      ninja-build), or can be downloaded from
      https://github.com/ninja-build/ninja/releases
    • pkg-config version 0.29.2
    ✗ GTK 3.0 development libraries are required for Linux development.
      They are likely available from your distribution (e.g.: apt install
      libgtk-3-dev)

[!] Android Studio (not installed)
    • Android Studio not found; download from
      https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup
      for detailed instructions).

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Linux Mint 21.3
      6.7.2-060702-generic
    • Chrome (web)    • chrome • web-javascript • Chromium 123.0.6312.58 for
      Linux Mint

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.

Info.plist (iOS)

No response

Podfile (iOS)

No response

AndroidManifest.xml

No response

MainActivity.java

No response

MainActivity.kt

No response

index.html

<!DOCTYPE html>
<html>

<head>
  <!--
    If you are serving your web app in a path other than the root, change the
    href value below to reflect the base path you are serving from.

    The path provided below has to start and end with a slash "/" in order for
    it to work correctly.

    For more details:
    * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base

    This is a placeholder for base href that will be replaced by the value of
    the `--base-href` argument provided to `flutter build`.
  -->
  <base href="$FLUTTER_BASE_HREF">

  <meta charset="UTF-8">
  <meta content="IE=Edge" http-equiv="X-UA-Compatible">
  <meta name="description" content="Simplism">

  <!-- iOS meta tags & icons -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="app">
  <link rel="apple-touch-icon" href="icons/Icon-192.png">

  <!-- Favicon -->
  <link rel="icon" type="image/png" href="favicon.png" />
  <link rel=”icon” href=”favicon.ico”>

  <title>app</title>
  <link rel="manifest" href="manifest.json">

  <script>
    // The value below is injected by flutter build, do not touch.
    var serviceWorkerVersion = null;
  </script>
  <!-- This script adds the flutter initialization JS code -->
  <script src="flutter.js" defer></script>
</head>

<body>
  <script>
    window.addEventListener('load', function (ev) {
      // Download main.dart.js
      _flutter.loader.loadEntrypoint({
        serviceWorker: {
          serviceWorkerVersion: serviceWorkerVersion,
        }
      }).then(function (engineInitializer) {
        return engineInitializer.initializeEngine();
      }).then(function (appRunner) {
        return appRunner.runApp();
      });
    });
  </script>
</body>

</html>

Info.plist (macOS)

No response

darwin-morocho commented 1 month ago

@jstdk this is not an issue of this plugin. Facebook has been disabled the login flow for localhost and http pages

jstdk commented 1 month ago

Thanks @darwin-morocho, I saw the warnings in console previously, but did not know it was blocked . Thanks.

jstdk commented 1 week ago

@darwin-morocho, I have moved to an https and can now fully complete the consent screen. Unfortunately, still only an "Instance of access token" response, even when I add a new developer account to the app for testing. My business is verified and advanced permissions are granted. Are you sure the plugin works fine?

Looks like a state management thing to me, as like the await is not properly respected on web.

    final LoginResult result = await FacebookAuth.instance.login(
        permissions: ["public_profile, pages_show_list, pages_messaging"]);
    print(result);
    if (result.status == LoginStatus.success) {
      FacebookPermissions? permissions =
          await FacebookAuth.instance.permissions;
      print(permissions);
      dynamic test = FacebookAuth.instance.getUserData();
      print(test);
      print(result.accessToken!);
    } else {
      print(result.status);
      print(result.message);
    }

Instance of 'LoginResult' Instance of 'FacebookPermissions' Instance of '_Future<Map<String, dynamic>>' Instance of 'AccessToken'