firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.71k stars 3.97k forks source link

🐛 [google_sign_in_web] Bad state: GoogleSignInPlugin::init() or GoogleSignInPlugin::initWithParams() must be called before any other method in this plugin. #12346

Closed thunderbug1 closed 8 months ago

thunderbug1 commented 8 months ago

Bug report

Describe the bug

I have a Flutter App targeting web only. Recently I started to get this issue:

[GSI_LOGGER]: Your client application uses one of the Google One Tap prompt UI status methods that may stop functioning when FedCM becomes mandatory. 
Refer to the migration guide to update your code accordingly and opt-in to FedCM to test your changes. 
Learn more: https://developers.google.com/identity/gsi/web/guides/fedcm-migration?s=dc#display_moment and https://developers.google.com/identity/gsi/web/guides/fedcm-migration?s=dc#skipped_moment

So to resolve this I am trying to port to the new SDK as described here README The description says that I need to use "renderButton" to show the Google sign in button on web. However, after adding the renderButton to the page and openening the login page in the browser I get this error as soon as the page is rendered:

Bad state: GoogleSignInPlugin::init() or GoogleSignInPlugin::initWithParams() must be called before
any other method in this plugin.

I could not find any existing issues about this error. The example app does not seem to have any init specific steps that need to be done so I am a bit confused.

Note: The meta tag with google-signin-client_id is added to the index.html and sign-in and sign-up already worked with the setup I had.

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.16.9, on Ubuntu 22.04.3 LTS 5.15.133.1-microsoft-standard-WSL2, locale en_US.UTF-8) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [✓] Linux toolchain - develop for Linux desktop [!] Android Studio (not installed) [✓] Connected device (1 available) [✓] Network resources ! Doctor found issues in 2 categories. ```

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand ``` Dart SDK 3.2.6 Flutter SDK 3.16.9 activilit 0.0.1+1 dependencies: - async 2.11.0 [collection meta] - cached_network_image 3.3.1 [cached_network_image_platform_interface cached_network_image_web flutter flutter_cache_manager octo_image] - cloud_firestore 4.15.4 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - cloud_functions 4.6.5 [cloud_functions_platform_interface cloud_functions_web firebase_core firebase_core_platform_interface flutter] - cream_of_the_crop 0.92.1 [flutter flutter_web_plugins plugin_platform_interface] - crop_image 1.0.12 [flutter] - cupertino_icons 1.0.6 - currency_picker 2.0.20 [flutter collection] - currency_text_input_formatter 2.1.13 [flutter intl] - enum_to_string 2.0.1 - equatable 2.0.5 [collection meta] - firebase_app_check 0.2.1+13 [firebase_app_check_platform_interface firebase_app_check_web firebase_core firebase_core_platform_interface flutter] - firebase_auth 4.17.4 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.25.4 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_messaging 14.7.15 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - firebase_storage 11.6.0 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - flutter 0.0.0 [characters collection material_color_utilities meta vector_math web sky_engine] - flutter_dotenv 5.1.0 [flutter] - flutter_lints 3.0.1 [lints] - flutter_map_cancellable_tile_provider 2.0.0 [dio flutter flutter_map meta] - flutter_oss_licenses 2.0.1 [path meta yaml dart_pubspec_licenses args] - flutter_riverpod 2.4.10 [collection flutter meta riverpod state_notifier] - flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math web] - geoflutterfire_plus 0.0.20 [cloud_firestore flutter rxdart] - geolocator 10.1.1 [flutter geolocator_platform_interface geolocator_android geolocator_apple geolocator_web geolocator_windows] - go_router 13.2.0 [collection flutter flutter_web_plugins logging meta] - google_fonts 6.1.0 [flutter http path_provider crypto] - google_sign_in 6.2.1 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web] - google_sign_in_web 0.12.3+2 [flutter flutter_web_plugins google_identity_services_web google_sign_in_platform_interface http web] - http 1.2.0 [async http_parser meta web] - image_compression_flutter 1.0.3 [flutter flutter_web_plugins cross_file flutter_image_compress image_compression] - image_cropper 5.0.1 [flutter image_cropper_platform_interface image_cropper_for_web] - image_cropper_for_web 3.0.0 [flutter flutter_web_plugins image_cropper_platform_interface js] - image_picker 1.0.7 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_linux image_picker_macos image_picker_platform_interface image_picker_windows] - image_size_getter 2.1.2 [collection hashcodes] - intl 0.19.0 [clock meta path] - location_picker_flutter_map 3.0.0 [flutter flutter_map geolocator http intl latlong2 url_launcher flutter_map_location_marker flutter_map_cancellable_tile_provider] - mailto 2.0.0 - maptiler_flutter 0.1.0 [http] - overlay_support 2.1.0 [flutter async] - package_info_plus 5.0.1 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface web win32] - page_view_indicators 2.0.0 [flutter] - platform_detect 2.0.11 [meta pub_semver] - pwa_install 0.0.5 [flutter js] - qr_flutter 4.1.0 [flutter qr] - reorderable_grid 1.0.10 [flutter] - sentry_flutter 7.16.0 [flutter flutter_web_plugins sentry package_info_plus meta ffi] - settings_ui 2.0.2 [flutter] - share_plus 7.2.2 [cross_file meta mime flutter flutter_web_plugins share_plus_platform_interface file url_launcher_web url_launcher_windows url_launcher_linux url_launcher_platform_interface ffi win32] - twicpics_components 0.2.1 [flutter flutter_cache_manager visibility_detector] - url_launcher 6.2.4 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] dev dependencies: - flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math async boolean_selector characters collection material_color_utilities meta source_span stream_channel string_scanner term_glyph web] transitive dependencies: - _flutterfire_internals 1.3.21 [collection firebase_core firebase_core_platform_interface flutter meta] - archive 3.4.10 [crypto path pointycastle] - args 2.4.2 - boolean_selector 2.1.1 [source_span string_scanner] - cached_network_image_platform_interface 4.0.0 [flutter flutter_cache_manager] - cached_network_image_web 1.1.1 [cached_network_image_platform_interface flutter flutter_cache_manager] - characters 1.3.0 - clock 1.1.1 - cloud_firestore_platform_interface 6.1.5 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 3.10.4 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - cloud_functions_platform_interface 5.5.16 [firebase_core flutter meta plugin_platform_interface] - cloud_functions_web 4.6.16 [cloud_functions_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - collection 1.18.0 - convert 3.1.1 [typed_data] - cross_file 0.3.3+8 [meta web] - crypto 3.0.3 [typed_data] - dart_pubspec_licenses 2.0.2 [yaml path json_annotation] - dio 5.4.0 [async http_parser meta path] - fake_async 1.3.1 [clock collection] - ffi 2.1.0 - file 7.0.0 [meta path] - file_selector_linux 0.9.2+1 [cross_file file_selector_platform_interface flutter] - file_selector_macos 0.9.3+3 [cross_file file_selector_platform_interface flutter] - file_selector_platform_interface 2.6.2 [cross_file flutter http plugin_platform_interface] - file_selector_windows 0.9.3+1 [cross_file file_selector_platform_interface flutter] - firebase_app_check_platform_interface 0.1.0+15 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_app_check_web 0.1.0+15 [_flutterfire_internals firebase_app_check_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_auth_platform_interface 7.1.4 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.9.4 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser js meta web] - firebase_core_platform_interface 5.0.0 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.11.4 [firebase_core_platform_interface flutter flutter_web_plugins js meta web] - firebase_messaging_platform_interface 4.5.23 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 3.6.4 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta web] - firebase_storage_platform_interface 5.1.3 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.6.17 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - fixnum 1.1.0 - flutter_cache_manager 3.3.1 [clock collection file flutter http path path_provider rxdart sqflite uuid] - flutter_compass 0.8.0 [flutter] - flutter_image_compress 1.1.3 [flutter] - flutter_map 6.1.0 [async collection flutter http latlong2 logger meta polylabel proj4dart vector_math] - flutter_map_location_marker 8.0.4 [flutter flutter_compass flutter_map geolocator latlong2] - flutter_plugin_android_lifecycle 2.0.17 [flutter] - geolocator_android 4.5.2 [flutter geolocator_platform_interface meta uuid] - geolocator_apple 2.3.6 [flutter geolocator_platform_interface] - geolocator_platform_interface 4.2.1 [flutter plugin_platform_interface vector_math meta] - geolocator_web 2.2.1 [flutter flutter_web_plugins geolocator_platform_interface] - geolocator_windows 0.2.2 [flutter geolocator_platform_interface] - google_identity_services_web 0.3.0+2 [meta web] - google_sign_in_android 6.1.21 [flutter google_sign_in_platform_interface] - google_sign_in_ios 5.7.3 [flutter google_sign_in_platform_interface] - google_sign_in_platform_interface 2.4.5 [flutter plugin_platform_interface] - hashcodes 2.0.0 - http_parser 4.0.2 [collection source_span string_scanner typed_data] - image 4.1.7 [archive meta xml] - image_compression 1.0.4 [image mime path] - image_cropper_platform_interface 5.0.0 [flutter plugin_platform_interface http] - image_picker_android 0.8.9+3 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - image_picker_for_web 3.0.2 [flutter flutter_web_plugins image_picker_platform_interface mime] - image_picker_ios 0.8.9+1 [flutter image_picker_platform_interface] - image_picker_linux 0.2.1+1 [file_selector_linux file_selector_platform_interface flutter image_picker_platform_interface] - image_picker_macos 0.2.1+1 [file_selector_macos file_selector_platform_interface flutter image_picker_platform_interface] - image_picker_platform_interface 2.9.3 [cross_file flutter http plugin_platform_interface] - image_picker_windows 0.2.1+1 [file_selector_platform_interface file_selector_windows flutter image_picker_platform_interface] - js 0.6.7 [meta] - json_annotation 4.8.1 [meta] - latlong2 0.9.0 [intl] - lints 3.0.0 - lists 1.0.1 [meta] - logger 2.0.2+1 - logging 1.2.0 - matcher 0.12.16 [async meta stack_trace term_glyph test_api] - material_color_utilities 0.5.0 [collection] - meta 1.10.0 - mgrs_dart 2.0.0 [unicode] - mime 1.0.5 - octo_image 2.0.0 [flutter] - package_info_plus_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - path 1.8.3 - path_provider 2.1.2 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows] - path_provider_android 2.2.2 [flutter path_provider_platform_interface] - path_provider_foundation 2.3.2 [flutter path_provider_platform_interface] - path_provider_linux 2.2.1 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_platform_interface 2.1.2 [flutter platform plugin_platform_interface] - path_provider_windows 2.2.1 [ffi flutter path path_provider_platform_interface win32] - petitparser 6.0.2 [meta] - platform 3.1.4 - plugin_platform_interface 2.1.8 [meta] - pointycastle 3.7.4 [collection convert js] - polylabel 1.0.1 [collection] - proj4dart 2.1.0 [mgrs_dart wkt_parser meta] - pub_semver 2.1.4 [collection meta] - qr 3.0.1 [meta] - riverpod 2.5.0 [meta stack_trace state_notifier] - rxdart 0.27.7 - sentry 7.16.0 [http meta stack_trace uuid] - share_plus_platform_interface 3.3.1 [cross_file flutter meta mime plugin_platform_interface path_provider uuid] - sky_engine 0.0.99 - source_span 1.10.0 [collection path term_glyph] - sprintf 7.0.0 - sqflite 2.3.2 [flutter sqflite_common path] - sqflite_common 2.5.3 [synchronized path meta] - stack_trace 1.11.1 [path] - state_notifier 1.0.0 [meta] - stream_channel 2.1.2 [async] - string_scanner 1.2.0 [source_span] - synchronized 3.1.0+1 - term_glyph 1.2.1 - test_api 0.6.1 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph] - typed_data 1.3.2 [collection] - unicode 0.3.1 [lists] - url_launcher_android 6.2.2 [flutter url_launcher_platform_interface] - url_launcher_ios 6.2.4 [flutter url_launcher_platform_interface] - url_launcher_linux 3.1.1 [flutter url_launcher_platform_interface] - url_launcher_macos 3.1.0 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.3.1 [flutter plugin_platform_interface] - url_launcher_web 2.2.3 [flutter flutter_web_plugins url_launcher_platform_interface web] - url_launcher_windows 3.1.1 [flutter url_launcher_platform_interface] - uuid 4.3.3 [crypto sprintf meta fixnum] - vector_math 2.1.4 - visibility_detector 0.4.0+2 [flutter] - web 0.3.0 - win32 5.2.0 [ffi] - wkt_parser 2.0.0 - xdg_directories 1.0.4 [meta path] - xml 6.5.0 [collection meta petitparser] - yaml 3.1.2 [collection source_span string_scanner] ```

thunderbug1 commented 8 months ago

I did some digging in the code of the renderbutton and added this to my main.dart:

import 'package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart'
    show GoogleSignInPlatform;
...
final plugin = GoogleSignInPlatform.instance as GoogleSignInPlugin;
      await plugin.init();

with this it at least renders the login page after hanging for a couple of seconds.

danagbemava-nc commented 8 months ago

Hi @thunderbug1, google_sign_in is not maintained on this repo. It is part of the flutter first party plugins. Please file a new issue on the flutter repo so that this can be properly addressed.

Closing from here.

Thank you