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

firebase_auth 1.0.3 #5728

Closed spacekestrel closed 3 years ago

spacekestrel commented 3 years ago

createUserWithEmailAndPassword() method on Flutter web does not work. Oh, and other package - flutter_auth_web does not work either. Trying to create new user with simple

 await FirebaseAuth.instance
            .createUserWithEmailAndPassword(
             email: 'user@user.user',
             password: '123123123');

gives

Error: [firebase_auth/network-request-failed] A network error (such as timeout, interrupted connection or unreachable host) has occurred.
    at Object.throw_ [as throw] (http://localhost:61255/dart_sdk.js:5334:11)
    at firebase_auth_web.FirebaseAuthWeb.new.createUserWithEmailAndPassword (http://localhost:61255/packages/firebase_auth_web/firebase_auth_web.dart.lib.js:149:23)
    at createUserWithEmailAndPassword.throw (<anonymous>)
    at http://localhost:61255/dart_sdk.js:39038:38
    at _RootZone.runBinary (http://localhost:61255/dart_sdk.js:38894:58)
    at _FutureListener.thenAwait.handleError (http://localhost:61255/dart_sdk.js:33887:48)
    at handleError (http://localhost:61255/dart_sdk.js:34451:51)
    at Function._propagateToListeners (http://localhost:61255/dart_sdk.js:34477:17)
    at _Future.new.[_completeError] (http://localhost:61255/dart_sdk.js:34323:23)
    at async._AsyncCallbackEntry.new.callback (http://localhost:61255/dart_sdk.js:34362:31)
    at Object._microtaskLoop (http://localhost:61255/dart_sdk.js:39176:13)
    at _startMicrotaskLoop (http://localhost:61255/dart_sdk.js:39182:13)
    at http://localhost:61255/dart_sdk.js:34689:9

Litterally everything is enabled. on index.html:

    <script src="https://www.gstatic.com/firebasejs/7.22.1/firebase-app.js"></script>
    <script src="https://www.gstatic.com/firebasejs/7.22.1/firebase-analytics.js"></script>
    <script src="https://www.gstatic.com/firebasejs/7.22.1/firebase-auth.js"></script>
    <script src="https://www.gstatic.com/firebasejs/7.22.1/firebase-firestore.js"></script>
    <script src="https://www.gstatic.com/firebasejs/7.22.1/firebase-storage.js"></script>
    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDm9vMbyvj_7lahfpYCKNAEDoWVITF0Rag"></script>

(yes, script file with firebase config is there also, i just didn't put it)

main.dart

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(MaterialAppInit());
}

And obviosly project is enabled in firebase itself and flutter doctor show all green(duuh).

Firefox says that it's CORS issue, btw, but i suspect version incompatibility also.

markusaksli-nc commented 3 years ago

Hi @spacekestrel Could you please provide your flutter doctor -v and flutter pub deps -- --style=compact? I just tested this with firebase_auth: ^1.0.3 and both the officially recommended JS import version 7.20.0 and the one you used but didn't see any issues using the official example.

flutter doctor -v ```console [√] Flutter (Channel master, 2.1.0-13.0.pre.574, on Microsoft Windows [Version 10.0.19041.867], locale et-EE) β€’ Flutter version 2.1.0-13.0.pre.574 at C:\Development\flutter_master β€’ Framework revision 02efffc134 (2 days ago), 2021-04-10 03:49:01 -0400 β€’ Engine revision 8863afff16 β€’ Dart version 2.13.0 (build 2.13.0-222.0.dev) [!] Android toolchain - develop for Android devices (Android SDK version 30.0.2) β€’ Android SDK at C:\Users\marku\AppData\Local\Android\sdk β€’ Platform android-30, build-tools 30.0.2 β€’ Java binary at: C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.7199119\jre\bin\java β€’ Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) X Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/windows#android-setup for more details. [√] Chrome - develop for the web β€’ Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.7) β€’ Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community β€’ Visual Studio Community 2019 version 16.7.30621.155 β€’ Windows 10 SDK version 10.0.18362.0 [√] Android Studio (version 4.1.0) β€’ Android Studio at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.7199119 β€’ Flutter plugin version 55.0.1 β€’ Dart plugin version 201.9335 β€’ Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) [√] IntelliJ IDEA Ultimate Edition (version 2021.1) β€’ IntelliJ at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\211.6693.111 β€’ 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 [√] Connected device (4 available) β€’ SM G950F (mobile) β€’ ce12171c51cc001c03 β€’ android-arm64 β€’ Android 9 (API 28) β€’ Windows (desktop) β€’ windows β€’ windows-x64 β€’ Microsoft Windows [Version 10.0.19041.867] β€’ Chrome (web) β€’ chrome β€’ web-javascript β€’ Google Chrome 89.0.4389.114 β€’ Edge (web) β€’ edge β€’ web-javascript β€’ Microsoft Edge 89.0.774.63 ! Doctor found issues in 1 category. ```

Are you using auth emulator? Could you try the official example as well? FYI firebase_auth_web is a transitive dependency for firebase_auth so you don't need to do anything with it directly. Thank you

spacekestrel commented 3 years ago

flutter doctor -v :

[√] Flutter (Channel stable, 2.0.3, on Microsoft Windows [Version 10.0.19042.685], locale ru-RU)
    β€’ Flutter version 2.0.3 at C:\Work\SDK\flutter
    β€’ Framework revision 4d7946a68d (4 weeks ago), 2021-03-18 17:24:33 -0700
    β€’ Engine revision 3459eb2436
    β€’ Dart version 2.12.2

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    β€’ Android SDK at C:\Users\kestrel\AppData\Local\Android\sdk
    β€’ Platform android-30, build-tools 30.0.3
    β€’ Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    β€’ Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    β€’ All Android licenses accepted.

[√] Chrome - develop for the web
    β€’ Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 4.1.0)
    β€’ 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 1.8.0_242-release-1644-b01)

[√] VS Code, 64-bit edition (version 1.55.0)
    β€’ VS Code at C:\Program Files\Microsoft VS Code
    β€’ Flutter extension version 3.21.0

[√] Connected device (3 available)
    β€’ Windows (desktop) β€’ windows β€’ windows-x64    β€’ Microsoft Windows [Version 10.0.19042.685]
    β€’ Chrome (web)      β€’ chrome  β€’ web-javascript β€’ Google Chrome 89.0.4389.114
    β€’ Edge (web)        β€’ edge    β€’ web-javascript β€’ Microsoft Edge 89.0.774.57

flutter pub deps -- --style=compact :

Dart SDK 2.12.2
Flutter SDK 2.0.3
quicklyby_web 1.0.0+1

dependencies:
- address_search_field 3.1.0-nullsafety.0 [flutter flutter_web_plugins http google_maps_flutter]
- awesome_card 1.1.0 [flutter]
- cloud_firestore 1.0.4 [cloud_firestore_platform_interface cloud_firestore_web firebase_core firebase_core_platform_interface flutter meta]        
- collapsible_sidebar 1.0.7+2 [flutter]
- condition 0.0.8 [flutter]
- cupertino_icons 1.0.2
- file_picker 3.0.0 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface]
- firebase_auth 1.0.3 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 1.0.3 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_storage 8.0.3 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_sequence_animation 3.0.1 [flutter meta]
- flutter_spinkit 4.1.2+1 [flutter]
- flutter_switch 0.3.0 [flutter]
- get 3.26.0 [flutter]
- google_maps_flutter 2.0.1 [flutter flutter_plugin_android_lifecycle google_maps_flutter_platform_interface]
- google_maps_flutter_web 0.2.1 [flutter flutter_web_plugins meta google_maps_flutter_platform_interface google_maps stream_transform sanitize_html]
- google_nav_bar 5.0.3 [flutter]
- hexcolor 2.0.3 [flutter flutter_web_plugins]
- http 0.13.1 [http_parser meta path pedantic]
- image_picker_web_redux 2.0.0 [flutter flutter_web_plugins]
- intl_phone_field 1.4.4 [flutter]
- line_icons 2.0.1 [flutter]
- multi_image_picker 4.8.00 [flutter meta]
- rflutter_alert 2.0.2 [flutter]

dev dependencies:
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]

transitive dependencies:
- async 2.5.0 [collection]
- boolean_selector 2.1.0 [source_span string_scanner]
- characters 1.1.0
- charcode 1.2.0
- clock 1.1.0
- cloud_firestore_platform_interface 4.0.1 [collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 1.0.4 [cloud_firestore_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js]
- collection 1.15.0
- csslib 0.17.0 [source_span]
- fake_async 1.2.0 [clock collection]
- firebase_auth_platform_interface 4.0.2 [firebase_core flutter meta plugin_platform_interface]
- firebase_auth_web 1.0.5 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta]
- firebase_core_platform_interface 4.0.0 [flutter meta plugin_platform_interface]
- firebase_core_web 1.0.2 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_storage_platform_interface 2.0.1 [collection firebase_core flutter meta plugin_platform_interface]
- firebase_storage_web 1.0.3 [async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta]
- flutter_plugin_android_lifecycle 2.0.0 [flutter]
- flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math]
- google_maps 3.4.5 [js_wrapping meta]
- google_maps_flutter_platform_interface 2.0.4 [flutter meta plugin_platform_interface stream_transform collection]
- html 0.15.0 [csslib source_span]
- http_parser 4.0.0 [charcode collection source_span string_scanner typed_data]
- intl 0.17.0 [clock path]
- js 0.6.3
- js_wrapping 0.5.0
- matcher 0.12.10 [stack_trace]
- meta 1.3.0
- path 1.8.0
- pedantic 1.11.0
- plugin_platform_interface 2.0.0 [meta]
- sanitize_html 2.0.0 [html meta]
- sky_engine 0.0.99
- source_span 1.8.0 [charcode collection path term_glyph]
- stack_trace 1.10.0 [path]
- stream_channel 2.1.0 [async]
- stream_transform 2.0.0
- string_scanner 1.1.0 [charcode source_span]
- term_glyph 1.2.0
- test_api 0.2.19 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.3.0 [collection]
- vector_math 2.1.0

Auth emulator? And what's the official example specifically?

spacekestrel commented 3 years ago

Oh, and when i tried to implement it as in basic example such as:

            try {
                                            UserCredential userCredential =
                                                await FirebaseAuth.instance
                                                    .createUserWithEmailAndPassword(
                                                        email:
                                                            "barry.allen@example.com",
                                                        password:
                                                            "SuperSecretPassword!");
                                          } on FirebaseAuthException catch (e) {
                                            if (e.code == 'weak-password') {
                                              print(
                                                  'The password provided is too weak.');
                                            } else if (e.code ==
                                                'email-already-in-use') {
                                              print(
                                                  'The account already exists for that email.');
                                            }
                                          } catch (e) {
                                            print(e);
                                          }

Chrome console gave me :

xhrio.js:630 POST https://www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key={//here is my key, obviously now for show} net::ERR_CONNECTION_REFUSED
markusaksli-nc commented 3 years ago

The official example is at https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_auth/firebase_auth/example/lib

Since I can't reproduce this it could have something to do with the config in index.html. You should double-check to make sure the values are correct https://firebase.flutter.dev/docs/installation/web#initializing-firebase

spacekestrel commented 3 years ago

The official example is at https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_auth/firebase_auth/example/lib

Since I can't reproduce this it could have something to do with the config in index.html. You should double-check to make sure the values are correct https://firebase.flutter.dev/docs/installation/web#initializing-firebase

WOW. What a help in two days. Thanks for nothing, Speedy Gonzales.

markusaksli-nc commented 3 years ago

Insults aren't going to get you anywhere here.

If the project credentials are correct you can try opening up the web build in a different browser or disabling your extensions to isolate the issue. Just the ERR_CONNECTION_REFUSED message isn't all that specific. What is the CORS issue you got on Firefox?

spacekestrel commented 3 years ago

Insults aren't going to get you anywhere here.

If the project credentials are correct you can try opening up the web build in a different browser or disabling your extensions to isolate the issue. Just the ERR_CONNECTION_REFUSED message isn't all that specific. What is the CORS issue you got on Firefox?

I guess that a lot of people depending on firebase, including flutterfire. And believe it or not - my job too. Being able to ask for flutter doctor and proceed with a bunch of watery words in two days - is a shitty support to say the least. I don't know if you get payed for this or you are a volunteer - you should stop doing this, because clearly - you are not very good at it.

In any case, i solve this issue. It was because i was using my mobile phone as a wifi hotspot, and since my mobile operator is greedy he want me to pay for creating hotspot. For purpose of avoiding it - i had to modify windows hosts file to add a lot of adresses(provided by my local community) , so my operator doesn't block internet. And when i delete those adresses - everything worked. So, yea. Please leave this job for someone, ho can actually do this.