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

🐛 [Firebase_Auth] SMS verification code request failed: Invalid request fields in play_integrity_token #11002

Closed Raaawezh closed 1 year ago

Raaawezh commented 1 year ago

Bug report

Describe the bug I'm encountering an issue with Firebase Authentication in Flutter after upgrading to Flutter 3.10 and updating the Firebase plugins. The authentication flow works fine on iOS devices, but on Android, I'm facing the following errors:

1- [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17028 Invalid request fields in play_integrity_token

2- This app is not authorized to use Firebase Authentication. Please verify that the correct package name, SHA-1, and SHA-256 are configured in the Firebase Console.

I have already configured the SHA-1 and SHA-256 values in the Firebase Console, and it was working correctly before the upgrades. To address these issues, I have also implemented app check in my code using the following snippet in the main method:


WidgetsFlutterBinding.ensureInitialized();

await Firebase.initializeApp(
  options: DefaultFirebaseOptions.currentPlatform,
);

await FirebaseAppCheck.instance.activate(
    webRecaptchaSiteKey: 'recaptcha-v3-site-key',

    androidProvider:
        kDebugMode ? AndroidProvider.debug : AndroidProvider.playIntegrity);

I'm uncertain if I'm missing something or if there are additional configurations required after the Flutter and Firebase plugin updates. Any assistance or insights would be greatly appreciated.

Flutter doctor

Click To Expand ``` Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.10.1, on Microsoft Windows [Version 10.0.19045.2965], locale en-US) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 33.0.2) [√] Chrome - develop for the web [!] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.1) X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components: MSVC v142 - VS 2019 C++ x64/x86 build tools - If there are multiple build tool versions available, install the latest C++ CMake tools for Windows Windows 10 SDK [√] Android Studio (version 2022.1) [√] VS Code (version 1.78.2) [√] Connected device (3 available) [√] Network resources ! Doctor found issues in 1 category. ```

Flutter dependencies

Click To Expand ``` Dart SDK 3.0.1 Flutter SDK 3.10.1 vary_pharmacy 1.0.0+1 dependencies: - cached_network_image 3.2.3 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web] - carousel_slider 4.2.1 [flutter] - convex_bottom_bar 3.2.0 [flutter] - cupertino_icons 1.0.5 - firebase_app_check 0.1.4+1 [firebase_app_check_platform_interface firebase_app_check_web firebase_core firebase_core_platform_interface flutter] - firebase_auth 4.6.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.13.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_messaging 14.6.1 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - flutter 0.0.0 [characters collection js material_color_utilities meta vector_math sky_engine] - flutter_html 3.0.0-beta.1 [html csslib collection list_counter flutter] - flutter_launcher_icons 0.11.0 [args checked_yaml cli_util image json_annotation path yaml] - flutter_local_notifications 12.0.4 [clock flutter flutter_local_notifications_linux flutter_local_notifications_platform_interface timezone] - flutter_secure_storage 8.0.0 [flutter flutter_secure_storage_linux flutter_secure_storage_macos flutter_secure_storage_platform_interface flutter_secure_storage_web flutter_secure_storage_windows meta] - flutter_svg 2.0.5 [flutter vector_graphics vector_graphics_codec vector_graphics_compiler] - http 0.13.6 [async http_parser meta] - image_picker 0.8.7+5 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_platform_interface] - infinite_scroll_pagination 3.2.0 [flutter sliver_tools] - intl 0.18.0 [clock meta path] - just_audio 0.9.33 [just_audio_platform_interface just_audio_web audio_session rxdart path path_provider async uuid crypto meta flutter] - lottie 2.3.2 [archive flutter path vector_math] - path_provider 2.0.15 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows] - photo_view 0.14.0 [flutter] - provider 6.0.5 [collection flutter nested] - record 4.4.4 [flutter record_platform_interface record_web record_windows record_macos record_linux] - shared_preferences 2.1.1 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] - signalr_netcore 1.3.3 [flutter logging tuple http web_socket_channel sse_client message_pack_dart] - smooth_page_indicator 1.1.0 [flutter] - url_launcher 6.1.11 [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_lints 2.0.1 [lints] - flutter_localizations 0.0.0 [flutter intl characters clock collection js material_color_utilities meta path vector_math] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection js matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] transitive dependencies: - _flutterfire_internals 1.3.1 [collection firebase_core firebase_core_platform_interface flutter meta] - archive 3.3.7 [crypto path pointycastle] - args 2.4.1 - async 2.11.0 [collection meta] - audio_session 0.1.14 [flutter flutter_web_plugins rxdart meta] - boolean_selector 2.1.1 [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.3.0 - checked_yaml 2.0.3 [json_annotation source_span yaml] - cli_util 0.3.5 [meta path] - clock 1.1.1 - collection 1.17.1 - convert 3.1.1 [typed_data] - cross_file 0.3.3+4 [js meta] - crypto 3.0.3 [typed_data] - csslib 0.17.2 [source_span] - dbus 0.7.8 [args ffi meta xml] - fake_async 1.3.1 [clock collection] - ffi 2.0.2 - file 6.1.4 [meta path] - firebase_app_check_platform_interface 0.0.8+1 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_app_check_web 0.0.10+1 [_flutterfire_internals firebase_app_check_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_auth_platform_interface 6.15.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.5.1 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser js meta] - firebase_core_platform_interface 4.8.0 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.5.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_messaging_platform_interface 4.5.1 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 3.5.1 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins 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_local_notifications_linux 2.0.0 [flutter flutter_local_notifications_platform_interface dbus path xdg_directories] - flutter_local_notifications_platform_interface 6.0.0 [flutter plugin_platform_interface] - flutter_plugin_android_lifecycle 2.0.14 [flutter] - flutter_secure_storage_linux 1.1.3 [flutter flutter_secure_storage_platform_interface] - flutter_secure_storage_macos 3.0.0 [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 2.0.0 [flutter flutter_secure_storage_platform_interface] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - html 0.15.3 [csslib source_span] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - image 3.3.0 [archive meta xml] - image_picker_android 0.8.6+15 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - image_picker_for_web 2.1.12 [flutter flutter_web_plugins image_picker_platform_interface] - image_picker_ios 0.8.7+4 [flutter image_picker_platform_interface] - image_picker_platform_interface 2.6.3 [cross_file flutter http plugin_platform_interface] - js 0.6.7 [meta] - json_annotation 4.8.1 [meta] - just_audio_platform_interface 4.2.1 [flutter plugin_platform_interface] - just_audio_web 0.4.8 [just_audio_platform_interface flutter flutter_web_plugins] - lints 2.1.0 - list_counter 1.0.2 - logging 1.1.1 - matcher 0.12.15 [async meta stack_trace term_glyph test_api] - material_color_utilities 0.2.0 - message_pack_dart 2.0.1 - meta 1.9.1 - nested 1.0.0 [flutter] - octo_image 1.0.2 [flutter flutter_blurhash] - path 1.8.3 - path_parsing 1.0.1 [vector_math meta] - path_provider_android 2.0.27 [flutter path_provider_platform_interface] - path_provider_foundation 2.2.3 [flutter path_provider_platform_interface] - path_provider_linux 2.1.10 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_platform_interface 2.0.6 [flutter platform plugin_platform_interface] - path_provider_windows 2.1.6 [ffi flutter path path_provider_platform_interface win32] - pedantic 1.11.1 - petitparser 5.4.0 [meta] - platform 3.1.0 - plugin_platform_interface 2.1.4 [meta] - pointycastle 3.7.3 [collection convert js] - process 4.2.4 [file path platform] - record_linux 0.4.1 [flutter record_platform_interface path] - record_macos 0.2.2 [flutter record_platform_interface] - record_platform_interface 0.5.0 [flutter plugin_platform_interface] - record_web 0.5.0 [flutter flutter_web_plugins record_platform_interface] - record_windows 0.7.1 [flutter record_platform_interface path] - rxdart 0.27.7 - shared_preferences_android 2.1.4 [flutter shared_preferences_platform_interface] - shared_preferences_foundation 2.2.2 [flutter shared_preferences_platform_interface] - shared_preferences_linux 2.2.0 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface] - shared_preferences_platform_interface 2.2.0 [flutter plugin_platform_interface] - shared_preferences_web 2.1.0 [flutter flutter_web_plugins shared_preferences_platform_interface] - shared_preferences_windows 2.2.0 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - sky_engine 0.0.99 - sliver_tools 0.2.10 [flutter] - source_span 1.9.1 [collection path term_glyph] - sqflite 2.2.8+4 [flutter sqflite_common path] - sqflite_common 2.4.5 [synchronized path meta] - sse_client 0.1.0 [http stream_channel] - stack_trace 1.11.0 [path] - stream_channel 2.1.1 [async] - string_scanner 1.2.0 [source_span] - synchronized 3.1.0 - term_glyph 1.2.1 - test_api 0.5.1 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - timezone 0.9.2 [path] - tuple 2.0.1 - typed_data 1.3.2 [collection] - url_launcher_android 6.0.34 [flutter url_launcher_platform_interface] - url_launcher_ios 6.1.4 [flutter url_launcher_platform_interface] - url_launcher_linux 3.0.5 [flutter url_launcher_platform_interface] - url_launcher_macos 3.0.5 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.1.2 [flutter plugin_platform_interface] - url_launcher_web 2.0.16 [flutter flutter_web_plugins url_launcher_platform_interface] - url_launcher_windows 3.0.6 [flutter url_launcher_platform_interface] - uuid 3.0.7 [crypto] - vector_graphics 1.1.5+1 [flutter vector_graphics_codec] - vector_graphics_codec 1.1.5+1 - vector_graphics_compiler 1.1.5+1 [args meta path_parsing xml vector_graphics_codec] - vector_math 2.1.4 - web_socket_channel 2.4.0 [async crypto stream_channel] - win32 4.1.4 [ffi] - xdg_directories 0.2.0+3 [meta path process] - xml 6.3.0 [collection meta petitparser] - yaml 3.1.2 [collection source_span string_scanner] ```

danagbemava-nc commented 1 year ago

Hi @Raaawezh, have you enabled play_integrity in your firebase console?

Is the issue in debug or release mode? If debug, have you uploaded the debug token to the firebase console? If in release mode, is the app from the store or are you running it locally? See similar discussions in https://github.com/invertase/react-native-firebase/issues/7030 & https://stackoverflow.com/questions/66848376/unknown-status-code-17028-a-safety-net-token-was-passed-but-no-matching-sha-25 to see if any of them help you out.

Raaawezh commented 1 year ago

Hi @Raaawezh, have you enabled play_integrity in your firebase console?

Is the issue in debug or release mode? If debug, have you uploaded the debug token to the firebase console? If in release mode, is the app from the store or are you running it locally? See similar discussions in invertase/react-native-firebase#7030 & https://stackoverflow.com/questions/66848376/unknown-status-code-17028-a-safety-net-token-was-passed-but-no-matching-sha-25 to see if any of them help you out.

hi, thank you for answering. the problem occurs in both debug and release modes (even play sotre release) i have already enabled play integrity and removed all restrictions on my keys in cloud projects and i do upload the debug token to firebase app check but still no luck. image even my old releases dont work anymore and they all give the same error.

and this is how the firebaseAuth code is called ( part of it ) image as i said it was working fine before idk why it stopped all of a sudden

danagbemava-nc commented 1 year ago

Hi @Raaawezh, can you try disabling safetynet in the console to see if it has any effect?

Also what versions of the flutter fire plugins were you using before you upgraded to the ones you're having the issue with?

Raaawezh commented 1 year ago

Hi @Raaawezh, can you try disabling safetynet in the console to see if it has any effect?

Also what versions of the flutter fire plugins were you using before you upgraded to the ones you're having the issue with?

hi, sorry for forgetting to close the issue. it started working again (somehow?) i still dont know what the problem was but after 3 days it started working again with no problems. thank u