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.66k stars 3.96k forks source link

🐛 [firebase_auth] Firebase Phone Authentication Not Sending SMS Code #11565

Closed yousefak007 closed 1 year ago

yousefak007 commented 1 year ago

Bug report

Describe the bug I am encountering an issue with Firebase phone authentication where the SMS verification code is not being sent and I am receiving error code 17499. Error code 17499 indicates an internal error with the message "Error code:39".

I have already tried several troubleshooting steps such as:

Despite these steps, I am still facing the issue. However, using a test phone number works without any issues.

Can someone please help me resolve this issue? Any help would be greatly appreciated. Thank you.


Additional context


Logs

I/PlayCore(27490): UID: [14368] PID: [27490] IntegrityService : requestIntegrityToken(IntegrityTokenRequest{nonce=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, cloudProjectNumber=xxxxxxxxxxxxx})
I/PlayCore(27490): UID: [14368] PID: [27490] IntegrityService : Initiate binding to the service.
I/PlayCore(27490): UID: [14368] PID: [27490] IntegrityService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.integrityservice.IntegrityService})
I/PlayCore(27490): UID: [14368] PID: [27490] IntegrityService : linkToDeath
I/PlayCore(27490): UID: [14368] PID: [27490] OnRequestIntegrityTokenCallback : onRequestIntegrityToken
I/PlayCore(27490): UID: [14368] PID: [27490] IntegrityService : Unbind from service.
W/System (27490): Ignoring header X-Firebase-Locale because its value was null.
2
I/System.out(27490): (HTTPLog)-Static: isSBSettingEnabled false

E/FirebaseAuth(27490): [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 18002 Invalid PlayIntegrity token; app not Recognized by Play Store.

D/FirebaseAuth(27490): Re-triggering phone verification with Recaptcha flow forced for phone number +967xxxxxxxxx

I/zzf (27490): ForceRecaptchaFlow from phoneAuthOptions = true, ForceRecaptchaFlow from firebaseSettings = false

W/JavaBinder(27490): BinderProxy is being destroyed but the application did not call unlinkToDeath to unlink all of its death recipients beforehand. Releasing leaked death recipient: com.google.android.play.integrity.internal.n
I/zygote64(27490): Do full code cache collection, code=247KB, data=174KB
I/zygote64(27490): After code cache collection, code=238KB, data=144KB
W/System (27490): Ignoring header X-Firebase-Locale because its value was null.
D/ViewRootImpl@756c5f5RecaptchaActivity: setView = DecorView@c11f8a[RecaptchaActivity] TM=true MM=false
D/ViewRootImpl@756c5f5RecaptchaActivity: dispatchAttachedToWindow

E/FirebaseAuth(27490): [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17499 Error code:39
I/flutter (27490): [firebase_auth/unknown] An internal error has occurred. [ Error code:39 ]

Flutter dependencies

firebase_core: ^2.15.1
firebase_messaging: ^14.6.7
firebase_auth: ^4.9.0

yousefak007 commented 1 year ago

Hi @darshankawar, I'm sorry to bother you, but this issue is very annoying. There is still no clear solution for it. I have published my app on the Google Play Store and released the official version. However, the SMS code issue is still present. Only test numbers are working. I have tried many solutions, but none of them have worked. I am not sure what else to do. I would appreciate your help in resolving this issue. Thank you for your time.

danagbemava-nc commented 1 year ago

Hi @yousefak007, is the country you're testing from in this list? https://firebase.google.com/support/faq#phone-auth-countries

Please note that not all countries are supported for phone authentication.

yousefak007 commented 1 year ago

Hi @danagbemava-nc ,

Thanks for your response. I appreciate you taking the time to help me with this issue.

My country is Yemen, which is one of the available countries for Firebase Auth.

I tried to download the Firebase Auth example and linked it to a new account, but it didn't work. It was previously working with the Android Device Verification and SafetyNet service.

danagbemava-nc commented 1 year ago

Hi @yousefak007, can you take a look at these to see if they help with your issue?

https://github.com/firebase/flutterfire/issues/10777#issuecomment-1535972513 https://stackoverflow.com/questions/76386725/smsretrieverhelper-sms-verification-code-request-failed-unknown-status-code-17

yousefak007 commented 1 year ago

Hi @danagbemava-nc ,

Thank you for your time.

I have indeed tried some of these steps before, and they did not work for me. I have checked them again, and I also uploaded a new version to the Google Play Store after the changes.

Here are the steps I took in order:

  1. I reviewed and copied the Debug Keys from the project.

image

  1. I did the same thing with the App Signing Keys from Google Play.

image

  1. I went to Firebase Project settings and verified that the previous keys were present and matched the previous one.

image

  1. I opened the App Check page and verified that my app was registered, along with verifying the SHA-256 of the App Signing Keys from Google Play and the Debug Keystore.

image

  1. I went back to the Google Play Store to the App Integrity page and verified that there were no tests, and I made sure that my project was connected to the Google Cloud service, I also modified Device Integrity and added all the options as shown in the image.

image

  1. I went to the Google Cloud page for the project, then I went to the credentials page.
  2. In the API Keys section, I clicked on the edit button for the Android Key.
  3. I added the ID of the application, and I also added the SHA1 key of the App Signing Keys from Google Play and the Debug Keystore.
  4. I saved it as shown in the image.

image

  1. I saw the check mark on the Android Key, then I waited for more than 15 minutes.

image

  1. After waiting, I went to the application and updated the Firebase settings through the command prompt.

image

image

image

  1. I verified that I had configured the settings correctly.

image

  1. I updated the AndroidManifest as shown in the image.

image

image

  1. Finally, I made a clean through the command prompt to make sure there was no cache, and then I made a new version and uploaded it to the stores.

image

image

image

image

Meanwhile, my app is currently under review. I will update you on the status after it is approved and I have had a chance to test it.

Thank you again


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` [√] Flutter (Channel stable, 3.7.12, on Microsoft Windows [Version 10.0.22621.2134], locale ar-SA) • Flutter version 3.7.12 on channel stable at C:\src\flutter_3.7.12_dart_2.19.6 • Upstream repository https://github.com/flutter/flutter.git • Framework revision 4d9e56e694 (5 months ago), 2023-04-17 21:47:46 -0400 • Engine revision 1a65d409c7 • Dart version 2.19.6 • DevTools version 2.20.1 [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at C:\Android\Sdk • Platform android-33, build-tools 33.0.0 • ANDROID_HOME = C:\Android\Sdk • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.6.0) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.6.33712.159 • Windows 10 SDK version 10.0.22000.0 [√] Android Studio (version 2021.1) • Android Studio at C:\Users\Yousef\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\211.7628.21. 2111.8309675 • Flutter plugin version 68.1.1 • Dart plugin version 211.7817 • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822) [√] Android Studio (version 2021.3) • Android Studio at C:\Program Files\Android\Android Studio • 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) [√] Android Studio (version 2022.2) • Android Studio at C:\Users\Yousef\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\222.4459.24. 2221.10121639 • Flutter plugin version 74.0.2 • Dart plugin version 222.4582 • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694) [√] IntelliJ IDEA Ultimate Edition (version 2019.3) • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2019.3 • 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 [√] VS Code (version 1.81.1) • VS Code at C:\Users\Yousef\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.24.0 [√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 12.0.22621.2134] • Chrome (web) • chrome • web-javascript • Google Chrome 116.0.5845.180 • Edge (web) • edge • web-javascript • Microsoft Edge 116.0.1938.69 [√] HTTP Host Availability • All required HTTP hosts are available • No issues found! ```

Flutter dependencies

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

Click To Expand ``` Dart SDK 2.19.6 Flutter SDK 3.7.12 mufex 2.0.1+12 dependencies: - animator 3.3.0 [flutter states_rebuilder] - avatar_glow 2.0.2 [flutter] - bot_toast 4.0.4 [flutter] - cached_network_image 2.5.1 [flutter flutter_cache_manager octo_image] - connectivity 3.0.6 [flutter meta connectivity_platform_interface connectivity_macos connectivity_for_web] - cupertino_icons 1.0.6 - double_back_to_close_app 2.1.0 [flutter] - firebase_auth 4.9.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.15.1 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_messaging 14.6.7 [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_datetime_picker 1.5.1 [flutter] - flutter_feather_icons 2.0.0+1 [flutter] - flutter_html 0.11.1 [html flutter] - flutter_localizations 0.0.0 [flutter intl characters clock collection js material_color_utilities meta path vector_math] - flutter_polyline_points 1.0.0 [flutter http] - flutter_spinkit 5.2.0 [flutter] - flutter_staggered_animations 1.1.1 [flutter] - flutter_staggered_grid_view 0.7.0 [flutter] - flutter_swiper 1.1.6 [flutter transformer_page_view flutter_page_indicator] - flutter_vector_icons 2.0.0 [flutter] - font_awesome_flutter 10.4.0 [flutter] - geocoding 2.0.3 [flutter geocoding_platform_interface] - geolocator 7.7.0 [flutter geolocator_platform_interface geolocator_android geolocator_apple geolocator_web] - getwidget 4.0.0 [flutter] - google_maps_flutter 2.1.2 [flutter flutter_plugin_android_lifecycle google_maps_flutter_platform_interface] - http 0.13.6 [async http_parser meta] - image_picker 0.8.4+5 [flutter flutter_plugin_android_lifecycle image_picker_for_web image_picker_platform_interface] - intl 0.17.0 [clock path] - line_awesome_icons 1.0.4+2 [flutter] - loading_gifs 0.3.0 [flutter] - lottie 2.3.2 [archive flutter path vector_math] - mqtt_client 9.8.1 [typed_data event_bus path crypto meta] - outline_material_icons 0.1.1 [flutter] - overlay_support 2.1.0 [flutter async] - pagination 0.1.0 [flutter] - path 1.8.2 - path_provider 2.0.9 [flutter path_provider_android path_provider_ios path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows] - permission_handler 8.2.0 [flutter meta permission_handler_platform_interface] - progress_dialog 1.2.4 [flutter] - provider 6.0.5 [collection flutter nested] - search_widget 1.0.2 [flutter flutter_keyboard_visibility] - shared_preferences 2.0.9 [flutter meta shared_preferences_android shared_preferences_ios shared_preferences_linux shared_preferences_macos shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] - simple_animations 5.0.2 [flutter collection] - sqflite 2.2.8+4 [flutter sqflite_common path] - virtual_keyboard 0.1.4 [flutter] dev dependencies: - flutter_launcher_icons 0.11.0 [args checked_yaml cli_util image json_annotation path yaml] - 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.5 [collection firebase_core firebase_core_platform_interface flutter meta] - archive 3.3.8 [crypto path pointycastle] - args 2.4.2 - async 2.10.0 [collection meta] - boolean_selector 2.1.1 [source_span string_scanner] - characters 1.2.1 - checked_yaml 2.0.3 [json_annotation source_span yaml] - cli_util 0.3.5 [meta path] - clock 1.1.1 - collection 1.17.0 - connectivity_for_web 0.4.0+1 [connectivity_platform_interface flutter_web_plugins flutter] - connectivity_macos 0.2.1+2 [flutter connectivity_platform_interface] - connectivity_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - convert 3.1.1 [typed_data] - cross_file 0.3.3+5 [js meta] - crypto 3.0.3 [typed_data] - csslib 0.16.2 [source_span] - event_bus 2.0.0 - fake_async 1.3.1 [clock collection] - ffi 2.0.2 - file 6.1.4 [meta path] - firebase_auth_platform_interface 6.18.0 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.8.0 [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.7.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_messaging_platform_interface 4.5.6 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 3.5.6 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - flutter_blurhash 0.5.0 [flutter meta] - flutter_cache_manager 2.1.2 [flutter path_provider uuid http path sqflite pedantic clock file rxdart image] - flutter_keyboard_visibility 0.7.0 [flutter] - flutter_page_indicator 0.0.3 [flutter] - flutter_plugin_android_lifecycle 2.0.16 [flutter] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - geocoding_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - geolocator_android 2.1.0 [flutter geolocator_platform_interface] - geolocator_apple 1.2.2 [flutter geolocator_platform_interface] - geolocator_platform_interface 2.3.6 [flutter plugin_platform_interface vector_math meta] - geolocator_web 2.0.6 [flutter flutter_web_plugins geolocator_platform_interface] - google_maps_flutter_platform_interface 2.4.1 [collection flutter plugin_platform_interface stream_transform] - html 0.14.0+4 [csslib source_span] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - image 3.3.0 [archive meta xml] - image_picker_for_web 2.2.0 [flutter flutter_web_plugins image_picker_platform_interface mime] - image_picker_platform_interface 2.9.1 [cross_file flutter http plugin_platform_interface] - js 0.6.5 [meta] - json_annotation 4.8.1 [meta] - matcher 0.12.13 [meta stack_trace] - material_color_utilities 0.2.0 - meta 1.8.0 - mime 1.0.4 - navigation_builder 0.0.3 [flutter] - nested 1.0.0 [flutter] - octo_image 0.3.0 [flutter flutter_blurhash] - path_provider_android 2.2.0 [flutter path_provider_platform_interface] - path_provider_ios 2.0.11 [flutter path_provider_platform_interface] - path_provider_linux 2.2.1 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_macos 2.0.7 [flutter path_provider_platform_interface] - path_provider_platform_interface 2.1.1 [flutter platform plugin_platform_interface] - path_provider_windows 2.2.1 [ffi flutter path path_provider_platform_interface win32] - pedantic 1.11.1 - permission_handler_platform_interface 3.11.5 [flutter meta plugin_platform_interface] - petitparser 5.1.0 [meta] - platform 3.1.2 - plugin_platform_interface 2.1.6 [meta] - pointycastle 3.7.3 [collection convert js] - rxdart 0.25.0 - shared_preferences_android 2.2.1 [flutter shared_preferences_platform_interface] - shared_preferences_ios 2.1.1 [flutter shared_preferences_platform_interface] - shared_preferences_linux 2.3.1 [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.3.1 [flutter plugin_platform_interface] - shared_preferences_web 2.2.1 [flutter flutter_web_plugins shared_preferences_platform_interface] - shared_preferences_windows 2.3.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - sky_engine 0.0.99 - source_span 1.9.1 [collection path term_glyph] - sqflite_common 2.4.5+1 [synchronized path meta] - stack_trace 1.11.0 [path] - states_rebuilder 6.3.0 [flutter flutter_localizations collection meta navigation_builder] - stream_channel 2.1.1 [async] - stream_transform 2.1.0 - string_scanner 1.2.0 [source_span] - synchronized 3.1.0 - term_glyph 1.2.1 - test_api 0.4.16 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - transformer_page_view 0.1.6 [flutter] - typed_data 1.3.2 [collection] - uuid 3.0.7 [crypto] - vector_math 2.1.4 - win32 4.1.4 [ffi] - xdg_directories 1.0.3 [meta path] - xml 6.2.2 [collection meta petitparser] - yaml 3.1.2 [collection source_span string_scanner] ```

yousefak007 commented 1 year ago

Hello again @danagbemava-nc,

My app was accepted in the store a little while ago, and I tested it, but unfortunately the same previous message and the same error, nothing has changed!

danagbemava-nc commented 1 year ago

Hi @yousefak007, what plan are you using on firebase?

Do you still have the following lines in your logs?

E/FirebaseAuth(27490): [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 18002 Invalid PlayIntegrity token; app not Recognized by Play Store.

E/FirebaseAuth(27490): [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17499 Error code:39
I/flutter (27490): [firebase_auth/unknown] An internal error has occurred. [ Error code:39 ]
yousefak007 commented 1 year ago

Hi @danagbemava-nc,

Hi @yousefak007, what plan are you using on firebase?

I am using Spark

Do you still have the following lines in your logs?

Yes, the following logs are from a few seconds ago:

2023-09-13 13:55:23.004 ١٧٦٥٠-١٩٠٥٩ FirebaseAuth            com.godev.mufex                      E  [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17499 Error code:39
2023-09-13 13:55:23.015 ١٧٦٥٠-١٧٦٥٠ FirebaseAuth            com.godev.mufex                      D  Invoking original failure callbacks after phone verification failure for +967xxxxxxxxx, error - An internal error has occurred. [ Error code:39 ]
2023-09-13 13:55:23.017 ١٧٦٥٠-١٧٧٧٧ flutter                 com.godev.mufex                      I  [firebase_auth/unknown] An internal error has occurred. [ Error code:39 ]
danagbemava-nc commented 1 year ago

Hi @yousefak007, have you tried reaching out to firebase support?

From what I'm seeing only the error code 39 seems to be that you have hit a limit for OTPs or that the app has been temporarily blocked for too many requests

yousefak007 commented 1 year ago

From what I'm seeing only the error code 39 seems to be that you have hit a limit for OTPs or that the app has been temporarily blocked for too many requests

Hi @danagbemava-nc ,

Thank you for your time and effort. I appreciate it.

I've already contacted Firebase support and they've said they'll get back to me within 2 business days. I'm currently waiting for their response.

It's strange that I'm getting this error code in more than one project. I've also tried upgrading my Firebase account, but that didn't resolve the issue. I downgraded my account after that didn't work.

I'll keep you updated as soon as I hear back from Firebase support.

Thanks

google-oss-bot commented 1 year ago

Hey @yousefak007. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

yousefak007 commented 1 year ago

I am currently working on resolving the issue with Firebase support. I have provided them with all the necessary information and am awaiting their response.

yousefak007 commented 1 year ago

Hi @danagbemava-nc ,

Thank you for your help with the verification issue.

I wanted to update you on the verification issue we were discussing.

I finally received a response from Firebase support after a long back-and-forth with them. They clearly told me that the issue is with the local carriers. They are the ones who are not sending us the verification message. This error message appears: "[firebase_auth/unknown] An internal error has occurred. [ Error code:39 ]". In other cases, different error messages appear, but less frequently than the previous message.

I am currently working on connecting my application directly to SMS services with local carriers. I am also investigating the possibility of using other Firebase services, such as creating an account via Google or email, etc.

danagbemava-nc commented 1 year ago

Hi @yousefak007, thanks for the update.

Unfortunately, since this is an issue with the local carriers, this is out of scope for this repo.

As such I'll be closing this issue.

If you do face any more issues, please do not hesitate to file a new issue.

Thank you