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.72k stars 3.97k forks source link

🐛 [firebase_auth] Authorization is not persistent for non-default firebase apps #10241

Closed evekeen closed 1 year ago

evekeen commented 1 year ago

Bug report

Describe the bug If you have several firebase apps, the auth is only persistent for the default one.

Steps to reproduce

Steps to reproduce the behavior:

  1. Create 2 firebase apps: one default and another one
  2. Sign in the second one
  3. Restart the app

Expected behavior

auth.authStateChanges().listen is called with the same user after the restart.

Sample code

final _auth = FirebaseAuth.instanceFor(app: Firebase.app(appName()));
_auth.authStateChanges().listen((User? user) {
  log('user: ${user}');
});

Additional context

It's a blocker for me since I cannot migrate my app to Flutter while having some parts of it still working in native code.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` [✓] Flutter (Channel stable, 3.3.10, on macOS 13.1 22C65 darwin-arm, locale en-US) • Flutter version 3.3.10 on channel stable at /opt/homebrew/Caskroom/flutter/3.3.10/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.0) • Android SDK at /Users/ivkin/Library/Android/sdk • Platform android-33, build-tools 33.0.0 • ANDROID_HOME = /Users/ivkin/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses [✓] Xcode - develop for iOS and macOS (Xcode 14.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14B47b • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.2) • 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.12+0-b1504.28-7817840) [✓] IntelliJ IDEA Ultimate Edition (version 2022.2.4) • IntelliJ at /Applications/IntelliJ IDEA.app • Flutter plugin version 71.2.5 • Dart plugin version 222.4459.16 [✓] Connected device (4 available) • Alex Ivkin iPhone (mobile) • 00008110-000C14D20EDA801E • ios • iOS 16.1.2 20B110 • iPhone 14 Pro Max (mobile) • 3E722BD1-E246-4EF9-BF86-B6071C95248B • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-1 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 13.1 22C65 darwin-arm • Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.124 ! Error: Alexander’s Apple Watch needs to connect to determine its availability. Check the connection between the device and its companion iPhone, and the connection between the iPhone and Xcode. Both devices may also need to be restarted and unlocked. (code 1) [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category. ```

Flutter dependencies

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

Click To Expand ``` Dart SDK 2.18.6 Flutter SDK 3.3.10 acetrace_feed 1.0.0+1 dependencies: - cached_network_image 3.2.2 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web] - carousel_slider 4.2.1 [flutter] - cloud_firestore 4.1.0 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - cloud_functions 4.0.5 [cloud_functions_platform_interface cloud_functions_web firebase_core firebase_core_platform_interface flutter] - collection 1.16.0 - cupertino_icons 1.0.5 - device_info_plus 8.0.0 [device_info_plus_platform_interface ffi file flutter flutter_web_plugins meta win32] - firebase_analytics 10.1.0 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_app_check 0.1.1+8 [firebase_app_check_platform_interface firebase_app_check_web firebase_core firebase_core_platform_interface flutter] - firebase_auth 4.1.3 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.4.1 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 3.0.8 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_database 10.0.9 [firebase_core firebase_core_platform_interface firebase_database_platform_interface firebase_database_web flutter] - firebase_remote_config 3.0.9 [firebase_core firebase_core_platform_interface firebase_remote_config_platform_interface firebase_remote_config_web flutter] - firebase_storage 11.0.6 [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 sky_engine] - flutter_facebook_auth 5.0.7 [flutter flutter_facebook_auth_platform_interface flutter_facebook_auth_web facebook_auth_desktop] - flutter_hooks 0.18.5+1 [flutter] - flutter_profile_picture 2.0.0 [flutter] - flutter_svg 1.1.6 [flutter meta path_drawing vector_math xml] - font_awesome_flutter 10.2.1 [flutter] - get_it 7.2.0 [async collection] - image_picker 0.8.6 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_platform_interface] - mixpanel_flutter 2.0.0 [flutter flutter_web_plugins js] - percent_indicator 4.2.2 [flutter] - pull_down_button 0.4.1 [flutter meta] - shared_preferences 2.0.15 [flutter shared_preferences_android shared_preferences_ios shared_preferences_linux shared_preferences_macos shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] - skeletons 0.0.3 [flutter] - stacked 3.0.0 [flutter get_it meta provider collection stacked_core universal_io] - stacked_services 0.9.8 [flutter stacked_core get crypto] - timeago 3.3.0 [intl] - url_launcher 6.1.7 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - very_good_infinite_list 0.7.0 [flutter] - video_player 2.4.8 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web] - video_thumbnail 0.5.3 [flutter] - visibility_detector 0.3.3 [flutter] dev dependencies: - flutter_lints 2.0.1 [lints] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] - google_fonts 3.0.1 [flutter http path_provider crypto] - storybook_flutter 0.11.3 [collection device_frame flutter freezed_annotation nested pointer_interceptor provider recase] - test 1.21.4 [analyzer async boolean_selector collection coverage http_multi_server io js node_preamble package_config path pool shelf shelf_packages_handler shelf_static shelf_web_socket source_span stack_trace stream_channel typed_data web_socket_channel webkit_inspection_protocol yaml test_api test_core] transitive dependencies: - _fe_analyzer_shared 47.0.0 [meta] - _flutterfire_internals 1.0.12 [collection firebase_core firebase_core_platform_interface flutter meta] - analyzer 4.7.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - args 2.3.1 - async 2.9.0 [collection meta] - boolean_selector 2.1.0 [source_span string_scanner] - cached_network_image_platform_interface 2.0.0 [flutter flutter_cache_manager] - cached_network_image_web 1.0.2 [flutter flutter_cache_manager cached_network_image_platform_interface] - characters 1.2.1 - clock 1.1.1 - cloud_firestore_platform_interface 5.10.0 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 3.2.0 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - cloud_functions_platform_interface 5.1.24 [firebase_core flutter meta plugin_platform_interface] - cloud_functions_web 4.3.13 [cloud_functions_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - convert 3.1.1 [typed_data] - coverage 1.6.1 [args logging package_config path source_maps stack_trace vm_service] - cross_file 0.3.3+2 [js meta] - crypto 3.0.2 [typed_data] - csslib 0.17.2 [source_span] - device_frame 1.1.0 [freezed_annotation flutter] - device_info_plus_platform_interface 7.0.0 [flutter meta plugin_platform_interface] - facebook_auth_desktop 0.0.8 [flutter http flutter_secure_storage flutter_facebook_auth_platform_interface] - fake_async 1.3.1 [clock collection] - ffi 2.0.1 - file 6.1.4 [meta path] - firebase_analytics_platform_interface 3.3.17 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.5.1+8 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_app_check_platform_interface 0.0.5+11 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_app_check_web 0.0.7+11 [_flutterfire_internals firebase_app_check_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_auth_platform_interface 6.11.3 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.1.3 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.5.2 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.3.9 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_database_platform_interface 0.2.2+17 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_database_web 0.2.1+19 [firebase_core firebase_core_web firebase_database_platform_interface flutter flutter_web_plugins js] - firebase_remote_config_platform_interface 1.1.29 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_remote_config_web 1.1.18 [firebase_core firebase_core_web firebase_remote_config_platform_interface flutter flutter_web_plugins js] - firebase_storage_platform_interface 4.1.24 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.3.16 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - flutter_blurhash 0.7.0 [flutter] - flutter_cache_manager 3.3.0 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid] - flutter_facebook_auth_platform_interface 4.1.1 [flutter plugin_platform_interface] - flutter_facebook_auth_web 4.1.1 [flutter flutter_web_plugins js flutter_facebook_auth_platform_interface] - flutter_plugin_android_lifecycle 2.0.7 [flutter] - flutter_secure_storage 7.0.1 [flutter flutter_secure_storage_linux flutter_secure_storage_macos flutter_secure_storage_platform_interface flutter_secure_storage_web flutter_secure_storage_windows meta] - flutter_secure_storage_linux 1.1.2 [flutter flutter_secure_storage_platform_interface] - flutter_secure_storage_macos 2.0.1 [flutter flutter_secure_storage_platform_interface] - flutter_secure_storage_platform_interface 1.0.1 [flutter plugin_platform_interface] - flutter_secure_storage_web 1.1.1 [flutter flutter_secure_storage_platform_interface flutter_web_plugins js] - flutter_secure_storage_windows 1.1.3 [flutter flutter_secure_storage_platform_interface] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - freezed_annotation 2.2.0 [collection json_annotation meta] - frontend_server_client 2.1.3 [async path] - get 4.6.5 [flutter] - glob 2.1.1 [async collection file path string_scanner] - html 0.15.1 [csslib source_span] - http 0.13.5 [async http_parser meta path] - http_multi_server 3.2.1 [async] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - image_picker_android 0.8.5+3 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - image_picker_for_web 2.1.10 [flutter flutter_web_plugins image_picker_platform_interface] - image_picker_ios 0.8.6+1 [flutter image_picker_platform_interface] - image_picker_platform_interface 2.6.2 [cross_file flutter http plugin_platform_interface] - intl 0.17.0 [clock path] - io 1.0.3 [meta path string_scanner] - js 0.6.4 - json_annotation 4.7.0 [meta] - lints 2.0.1 - logging 1.1.0 - matcher 0.12.12 [stack_trace] - material_color_utilities 0.1.5 - meta 1.8.0 - mime 1.0.3 - nested 1.0.0 [flutter] - node_preamble 2.0.1 - octo_image 1.0.2 [flutter flutter_blurhash] - package_config 2.1.0 [path] - path 1.8.2 - path_drawing 1.0.1 [vector_math meta path_parsing flutter] - path_parsing 1.0.1 [vector_math meta] - path_provider 2.0.11 [flutter path_provider_android path_provider_ios path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows] - path_provider_android 2.0.22 [flutter path_provider_platform_interface] - path_provider_ios 2.0.11 [flutter path_provider_platform_interface] - path_provider_linux 2.1.7 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_macos 2.0.6 [flutter path_provider_platform_interface] - path_provider_platform_interface 2.0.5 [flutter platform plugin_platform_interface] - path_provider_windows 2.1.3 [ffi flutter path path_provider_platform_interface win32] - pedantic 1.11.1 - petitparser 5.1.0 [meta] - platform 3.1.0 - plugin_platform_interface 2.1.3 [meta] - pointer_interceptor 0.9.3+3 [flutter] - pool 1.5.1 [async stack_trace] - process 4.2.4 [file path platform] - provider 6.0.4 [collection flutter nested] - pub_semver 2.1.3 [collection meta] - recase 4.1.0 - rxdart 0.27.7 - shared_preferences_android 2.0.14 [flutter shared_preferences_platform_interface] - shared_preferences_ios 2.1.1 [flutter shared_preferences_platform_interface] - shared_preferences_linux 2.1.2 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface] - shared_preferences_macos 2.0.5 [flutter shared_preferences_platform_interface] - shared_preferences_platform_interface 2.1.0 [flutter plugin_platform_interface] - shared_preferences_web 2.0.4 [flutter flutter_web_plugins shared_preferences_platform_interface] - shared_preferences_windows 2.1.2 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - shelf 1.4.0 [async collection http_parser path stack_trace stream_channel] - shelf_packages_handler 3.0.1 [path shelf shelf_static] - shelf_static 1.1.1 [convert http_parser mime path shelf] - shelf_web_socket 1.0.3 [shelf stream_channel web_socket_channel] - sky_engine 0.0.99 - source_map_stack_trace 2.1.1 [path source_maps stack_trace] - source_maps 0.10.11 [source_span] - source_span 1.9.0 [collection path term_glyph] - sqflite 2.2.0+3 [flutter sqflite_common path] - sqflite_common 2.4.0+2 [synchronized path meta] - stack_trace 1.10.0 [path] - stacked_core 1.2.4 [get_it] - stream_channel 2.1.0 [async] - string_scanner 1.1.1 [source_span] - synchronized 3.0.0+3 - term_glyph 1.2.1 - test_api 0.4.12 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - test_core 0.4.16 [analyzer async args boolean_selector collection coverage frontend_server_client glob io meta package_config path pool source_map_stack_trace source_maps source_span stack_trace stream_channel vm_service yaml matcher test_api] - typed_data 1.3.1 [collection] - universal_io 2.0.4 [collection crypto meta typed_data] - url_launcher_android 6.0.22 [flutter url_launcher_platform_interface] - url_launcher_ios 6.0.17 [flutter url_launcher_platform_interface] - url_launcher_linux 3.0.1 [flutter url_launcher_platform_interface] - url_launcher_macos 3.0.1 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.1.1 [flutter plugin_platform_interface] - url_launcher_web 2.0.13 [flutter flutter_web_plugins url_launcher_platform_interface] - url_launcher_windows 3.0.1 [flutter url_launcher_platform_interface] - uuid 3.0.7 [crypto] - vector_math 2.1.2 - video_player_android 2.3.9 [flutter video_player_platform_interface] - video_player_avfoundation 2.3.7 [flutter video_player_platform_interface] - video_player_platform_interface 5.1.4 [flutter plugin_platform_interface] - video_player_web 2.0.12 [flutter flutter_web_plugins video_player_platform_interface] - vm_service 9.4.0 - watcher 1.0.2 [async path] - web_socket_channel 2.2.0 [async crypto stream_channel] - webkit_inspection_protocol 1.2.0 [logging] - win32 3.1.1 [ffi] - xdg_directories 0.2.0+2 [meta path process] - xml 6.1.0 [collection meta petitparser] - yaml 3.1.1 [collection source_span string_scanner] ```

darshankawar commented 1 year ago

Thanks for the report @evekeen Using the plugin example and following the steps to replicate, I am getting user back as null. Is this a correct interpretation of the behavior you are reporting ?

evekeen commented 1 year ago

Thanks for the report @evekeen Using the plugin example and following the steps to replicate, I am getting user back as null. Is this a correct interpretation of the behavior you are reporting ?

It seems correct

darshankawar commented 1 year ago

Thanks for the report. Keeping this issue open for team's attention and on expected behavior.

/cc @Lyokone

evekeen commented 1 year ago

@Lyokone @darshankawar this issue is critical for my project. Can you provide a fix or a workaround?

Lyokone commented 1 year ago

@evekeen I'm looking into this issue this week.

Lyokone commented 1 year ago

@evekeen Using the linked example app, modified to use a named app 'foo', I stay connected between app usage. Can you provide a complete example app?

evekeen commented 1 year ago

@Lyokone indeed it was just my bad setup