Sorry failed to sign in firebase error auth network request failed

[REQUIRED] Describe your environment Operating System version: Mac 10.14.6 Browser version: Chrome Version 79.0.3945.130 Firebase SDK version: 6.6.2 Firebase Product: auth (auth, database, storage,...

Comments

@shirlev-wix

[REQUIRED] Describe your environment

  • Operating System version: Mac 10.14.6
  • Browser version: Chrome Version 79.0.3945.130
  • Firebase SDK version: 6.6.2
  • Firebase Product: auth (auth, database, storage, etc)
  • React Native version: 0.61.5

[REQUIRED] Describe the problem

Getting an error when running on debug mode on the simulator (both for ios and android)

code: "auth/network-request-failed"
message: "A network error (such as timeout, interrupted connection or unreachable host) has 
occurred."
  • Works fine on the simulator when I’m not debugging.
  • Happens also for other teammates that work on the same project
  • Rebooting Chrome didn’t help

Steps to reproduce:

Relevant Code:

I created a small react native app to reproduce the bug:
https://github.com/shirlev-wix/firebase-bug

return Promise.resolve()
        .then(() => firebase.initializeApp(options, this.name))
        .then(app => app.auth().signInWithCustomToken(authKey)

Thanks!

bentzy, drorbiran, wafisher, groomain, cvharris, camille-mtti, Modjular, avinashg-wal, frunkad, myoldwang, and 10 more reacted with thumbs up emoji

@shirlev-wix
shirlev-wix

changed the title
auth/network-request-failed firebase when debugging on react native

auth/network-request-failed when debugging on react native

Feb 20, 2020

@rommelpe

Thanks for the report, @shirlev-wix. While I’m trying to replicate this, can you try using the latest version (7.8.2)? Most of these reports tend to be network related. If you can get network logs, that would be very helpful.

@rommelpe

@shirlev-wix I’m trying to reproduce this issue but haven’t been able to. Putting your working repro up on StackBlitz would be very helpful as we could fork it and might help you get it running. Thanks!

@google-oss-bot

Hey @shirlev-wix. 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 3 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!

@shirlev-wix

@shirlev-wix

Hi @rommelpe! Any updates regarding this one?
It is really making our life harder when trying to debug things related to firebase.

@kishansbs

same issue —

code: «auth/network-request-failed», message: «A network error (such as timeout, interrupted connection or unreachable host) has occurred.»

"firebase": "^7.13.2",
"react": "16.9.0",
"react-native": "0.61.5",

@nyenye

Not sure is the same, but I get a an error saying I have no connection on my device on an Android Emulator, but making requests with i.e. unfetch library, work just fine.

edit: In my case it happens with await Firestore.collection('users').get()

@berndartmueller

Our users experience the same auth/network-request-failed firebase auth issues since some time now. It mainly happens to Android Chrome users and the issue start immediately after/during using firebase.auth().signInAnonymously. (Note: I’m not using react, I simply use plain old Node.js SSR with vanilla js)

I’m also having a hard time reproducing the issue, I tried many real devices as well as devices on Browserstack. I’m just not getting this issue.

I already made sure that

  • there is no form html tag used
  • the call to action button is a <button type='button'>Signup</button> element
  • no session cookie/token revocation happens

Any ideas or any idea how I could reproduce it myself? Thanks a lot!

@jefelewis

I’m receiving the same issue with React. I was testing logging in and it was returning a user object. 10 or so times later, it just stopped working and I have got the message Error: A network error (such as timeout, interrupted connection or unreachable host) has occurred. for the past 12 hours.

Possible ways to resolve?
Is this possibly a limit issue? Should I delete node_modules and do a fresh install of the the npm packages? Should I downgrade the firebase library?

"firebase": "^7.15.1",
"react": "^16.13.1",
"redux": "^4.0.5",
"redux-persist": "^6.0.0",
"redux-saga": "^1.1.3",
"redux-saga-firebase": "^0.15.0"

@HassanAbass

I’m facing the same error when trying to use google/facebook signing with popup, used to work before and nothing change in the code.

//version
"firebase": "^7.15.5"

let provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider).then(e => ...)

@mogwely

Im facing the same error using google to sign in with signInWithPopup. Works for some users just fine but fails for other users.
//version
«firebase»: «^7.15.5»

@frietkip

I am running into the same error using google to sign in to my web app build with next js and deployed on vercel. Both on local, development and production.
image

«firebase»: «^7.14.2»,

Please advice

@avolkovi

Folks-

Thanks for reporting this, does anyone have a trace for the endpoint and underlying error (like in #3081 (comment))? The Network Error you are seeing is a generic error we throw when the underlying fetch() call fails.

@HassanAbass

In my case with signInWithPopup the pop up url (app-name/__/auth/…) was unreachable and no redirect to facebook/google happens, it worked again days later without changing anything.

@google-oss-bot

Hey @shirlev-wix. We need more information to resolve this issue but there hasn’t been an update in 5 weekdays. I’m marking the issue as stale and if there are no new updates in the next 5 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!

@shirlev-wix

@fersucho

Hey guys, I was having the same issue in an AngularJS app. In this comment:
#20 (comment)
It is explained that Firebase checks for navigator.online before doing the auth process, and sometimes (and in some cases, always) it receives a wrong answer. By adding the cordova-plugin-network-information to the project, it provides the correct answer to Firebase and the app works again.
In my case, I tried with version 2.0.2 of the plugin without success, and then with version 1.2.1 and, my app started to work fine.

@SpectorHacked

Also having this issue using Expo, can’t connect through Specific Wifi, connected 3 clients that are connected to the same WiFi,1 client works and 2 doesn’t work, using Expo SDK 39. Any Updates?

@HasanAboShally

I’m facing the same issue! Any update or workarounds please?

@HasanAboShally

In my case the issue was resolved by changing the authDomain to {{APP_ID}}.firebaseapp.com instead of {{APP_ID}}.web.app

@lewischa

Seeing the same issue here on firebase@8.2.6.

  • Tried switching networks.
  • Ensured my authDomain is {{APP_ID}}.firebaseapp.com
  • navigator.onLine is true
  • Even tried deleting my firebase project and re-creating it.
  • Button is not inside a <form> element. I also tried just attaching a function to window, completely removing a button from the equation — no dice:
    import firebase from 'firebase/app';
    import 'firebase/auth';
    import 'firebase/firestore';
    
    import { firebaseConfig } from './config';
    
    firebase.initializeApp(firebaseConfig);
    
    export const auth = firebase.auth();
    
    auth.onAuthStateChanged((user) => {
        console.log('firebase user:', user);
    });
    
    const GoogleProvider = new firebase.auth.GoogleAuthProvider();
    
    export const logInWithGoogle = () => {
        auth.signInWithPopup(GoogleProvider)
            .then((result) => {
                console.log('LOGGED IN!!! User:', result.user);
            })
            .catch((error) => {
                console.log('LOGIN ERROR!! :(', error);
            });
    };
    
    export const logInWithEmail = (email, password) => {
        auth.signInWithEmailAndPassword(email, password)
            .then((user) => {
                console.log('User signed in via email:', user);
            })
            .catch((error) => {
                console.log('error signing in with email:', error);
            });
    };
    
    // Invoking this results in the same `auth/network-request-failed` error
    window.testLogin = logInWithGoogle;

Was planning to switch from AWS for a small project but looks like this issue’s been around for almost a year now. Got stoked at how easy things are supposed to be to set up, and immediately ran into this!! 😬 😞

@HellBlazer616

Well we were having the same issue on our website. Turns out for us the problem was that we switched hosting from firebase to vercel. And the route that was loading the pop up «_example.com/_auth/apiKey?… » was not free anymore. Chrome was not showing anything but firefox was showing our 404 page. So, we figured it was a DNS issue. We got it to working by switching to the default auth domain. We are now working on configuring a custom auth sub domain for our site. I will post an update if we figure that out

@ayyfahim

I was facing the same issue. It turned out that I was caching everything on my service worker js file. So I disabled these domains.
if ( url.origin === "https://securetoken.googleapis.com" || url.origin === "https://apis.google.com" || url.origin === "https://www.googleapis.com" ) { return; }

@iamdevlinph

Our react app is suddenly this issue. Already disabled service workers. Also verified the Sign in with Google button is not in a form.

@tuancaraballo

Running into the same issue. Have tried everything said here, except for switching to a different product :(

@DonLuc

It looks like we’re rocking on the same boat.
I had createUserWithEmailAndPassword working well for a few hours on my Ionic App, running on Angular, and using AngularFireAuth.

What surprises me is that invoking AngularFireAuth’s sendPasswordResetEmail works well without resulting in this troubling authError.

These are the versions of the Angular, Ionic, and firebase related dependencies I’m using:

  • «@ionic/angular»: «^5.5.2»
  • «@types/firebase»: «^3.2.1»,
  • «@angular/fire»: «^7.0.4».

Please kindly unblock me.

@emthomas

facing the same on flutter in iOS.

@emthomas

Ok not sure if that is the case for react-native, but for me and flutter, looks like it was a caching issue. Once I do clean with flutter clean (which cleans my XCode workspace, build folder, cache, etc…) it works fine.

@Adefunke

Had the same issue but discovered that I was not passing in strings into ‘createUserWithEmailAndPassword’, I was passing in elements. Once, I switched to strings, I stopped getting auth/network-request-failed error.

@mayankkataria

I’m still facing this issue with firebase emulator on angular. Is there any solution or workaround for it?

@mayankkataria

I’m still facing this issue with firebase emulator on angular. Is there any solution or workaround for it? And I’m shocked that it’s still open since 2 years.

@rupakhetibinit

Well, looks like it’s still not fixed because I’m facing the same error.

@lghimfus

@code-odyssey-trunk, @SpectorHacked (hope you were not really hacked)

Did you find out eventually what was causing the issue?

I’m facing the same issue and it’s a really weird one. I have to switch through the wifi networks and it somehow eventually works…

@mogwely

I can second this behavior. I tell my users to switch networks and use their phones hotspot to go around this issue.

@mogwely

I’m sure firebase team either don’t care or don’t know how to solve this issue, but they are definitely aware of it. There has been countless tickets and SO questions regrding that issue.

@qq280948982

@lewiscasewell

I have the same issue too. Works fine in mobile browsers, however, when downloading PWA, get (auth/network-request-failed) error. Then after, removing another app from firebase, to just have one web app for the project.. it works fine again.

@FortyXD

Look, this can happen because the function does not have enough time to execute. Make it asynchronous. I solved the problem this way. Example:

 await this.fireservise.UpdateData(name,group).then(()=>{
        location.reload()
      })

 async UpdateData( name:string, grpup:string){
    const auth:any = getAuth();
  await updateProfile(auth.currentUser, {
     displayName: name, photoURL:  grpup
   }).then(() => {
     localStorage.setItem('Name',name)
     localStorage.setItem('Group',grpup)
   }).catch((error) => {
    alert("Error")
   });
  }

@rpelissier

In case it helps someone.
I had the same issue and lost many hours investigating.
It turned out that in my case, it was simply a DNS issue in the firebase layer.
localhost in the URL of the emulator was not resolved.
I replaced it with 127.0.0.1 and it is working fine.

It would have been really easier if the error message was not hiding the stack trace.

@guptavishesh143

I also faced the same issue, but while switching the data networks it started working! I switched from Wifi to Mobile Data.

@web3-king

I have the same issue. But I didn’t find the solution yet. How can I fix that?

@Maracaipe611

Same problem here…
My dependencies:
{ "firebase": "^9.12.1", "next": "12.2.5", "react": "18.2.0", }

Error message: Firebase: Error (auth/network-request-failed).
I already checked all my authorized domains in console.firebase, and the other’s requests like login & signing is fine. Just the reset password give me this error

@wendelfreitas

Still happening when I try to mock firebase rest API using nock on jest

  "dependencies": {
    "@react-query-firebase/auth": "^1.0.0-dev.2",    "firebase": "^9.12.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-query": "^3.39.2",
    "react-router-dom": "^6.4.2",
  },

@SSOURABH58

Hi, can you elaborate on the steps?
I am unable to get the DNS firebase layer part where exactly do I have to replace the localhost with 127.0.0.1?
( in my code or in the firebase or cloud console ??)
image

@web3-king

@MarioBatalha

Someone here already solved this issue?

An authentication error.
For method-specific error codes, refer to the specific methods in the
documentation. For common error codes, check the reference below. Usefirebase.auth.Error.code to get the specific error code. For a detailed
message, use firebase.auth.Error.message.
Errors with the code auth/account-exists-with-different-credential
will have the additional fields email and
credential
which are needed to provide a way to resolve these
specific errors. Refer to firebase.auth.Auth.signInWithPopup for more
information.

Common Error Codes

auth/app-deleted
Thrown if the instance of FirebaseApp has been deleted.
auth/app-not-authorized
Thrown if the app identified by the domain where it’s hosted, is not
authorized to use Firebase Authentication with the provided API key.
Review your key configuration in the Google API console.
auth/argument-error
Thrown if a method is called with incorrect arguments.
auth/invalid-api-key
Thrown if the provided API key is invalid. Please check that you have
copied it correctly from the Firebase Console.
auth/invalid-user-token
Thrown if the user’s credential is no longer valid. The user must sign in
again.
auth/invalid-tenant-id
Thrown if the tenant ID provided is invalid.
auth/network-request-failed
Thrown if a network error (such as timeout, interrupted connection or
unreachable host) has occurred.
auth/operation-not-allowed
Thrown if you have not enabled the provider in the Firebase Console. Go
to the Firebase Console for your project, in the Auth section and the
Sign in Method tab and configure the provider.
auth/requires-recent-login
Thrown if the user’s last sign-in time does not meet the security
threshold. Use firebase.User.reauthenticateWithCredential to
resolve. This does not apply if the user is anonymous.
auth/too-many-requests
Thrown if requests are blocked from a device due to unusual activity.
Trying again after some delay would unblock.
auth/unauthorized-domain
Thrown if the app domain is not authorized for OAuth operations for your
Firebase project. Edit the list of authorized domains from the Firebase
console.
auth/user-disabled
Thrown if the user account has been disabled by an administrator.
Accounts can be enabled or disabled in the Firebase Console, the Auth
section and Users subsection.
auth/user-token-expired
Thrown if the user’s credential has expired. This could also be thrown if
a user has been deleted. Prompting the user to sign in again should
resolve this for either case.
auth/web-storage-unsupported
Thrown if the browser does not support web storage or if the user
disables them.

Index

Properties

code

code: string

message

message: string

name

name: string

I’m running into a strange problem with my Firebase project when I try to use Password authentication. It works most of the time in Chrome (occasionally will result in this error), but when I run my app on an emulator or phone (Android), (at least) the first login attempt per load always results in an «Auth/network-request-failed» error. Here is my relevant Firebase code:

<script src="https://www.gstatic.com/firebasejs/3.2.1/firebase.js"></script>

. . .

$(document).on('click', '#loginButton', function() {
          var email = document.getElementById("loginEmail").value;
          var password = document.getElementById("loginPassword").value;
          firebase.auth().signInWithEmailAndPassword(email, password).then(function() {
            user = firebase.auth().currentUser;
            //Load in the user's pets and then switch to the "My Pets" page.
            $.getJSON('https://petspot-a43e7.firebaseio.com/users/' + user.uid + '/pets.json', function(data) {
              pets = {};
              for (var key in data) {
                pets[key] = JSON.parse(data[key]);
              }
            }).then(function() {
              $("#header").removeClass("invisible");
              Materialize.toast('Logged in successfully!', 2000, 'bottom');
              changePage("page1");
            });
            //Load the user's username and modify the sidebar accordingly.
            $.getJSON('https://petspot-a43e7.firebaseio.com/users/' + user.uid + '/username.json', function(data) {
              $("#sidebarName").html(data);
              $("#sidebarEmail").html(user.email);

            });
          }).catch(function(error) {
            // Handle Errors here.
            var errorCode = error.code;
            console.log(errorCode);
            var errorMessage = error.message;
            if (errorCode == "auth/user-disabled") {
              $('#' + "user-disabled").openModal();
            } else if (errorCode == "auth/user-not-found") {
              $('#' + "user-not-found").openModal();
            } else if (errorCode == "auth/too-many-requests") {
              $('#' + "too-many-requests").openModal();
            } else if (errorCode == "auth/wrong-password") {
              $('#' + "wrong-password").openModal();
            } else {
              alert(errorCode);
              alert(errorMessage);
            }
          });   

Any help would be greatly appreciated. Thank you all so much!

Я использую firebase Hosting для размещения моего веб-сайта, я пытаюсь войти в систему с помощью email/pwd, но эта ошибка постоянно появляется.

Это JS я использую:

window.onload = () => initApp(); //Initiate screen

function initApp(){
console.log(firebase);

document.getElementById("btnLogin").addEventListener("click", e => {
var email = document.getElementById("inputEmail").value;
var pwd = document.getElementById("inputPassword").value;

firebase.auth().signInWithEmailAndPassword(email, pwd).catch(error => {
var errorCode = error.code;
var errorMessage = error.message;
console.log(errorCode + "-" + errorMessage);
alert(errorCode + "-" + errorMessage);
}); //Login
});//Login button click

firebase.auth().onAuthStateChanged(user => {
console.log("User: " + user);
if (user) {
// User is signed in.
var displayName = user.displayName;
var uEmail = user.email;
var emailVerified = user.emailVerified;
var photoURL = user.photoURL;
var isAnonymous = user.isAnonymous;
var uid = user.uid;
var providerData = user.providerData;
console.log(uEmail + " logged in");
alert(uEmail + " logged in");
} else {
console.log("not logged in");
alert("not logged in");
}//Check user
});//Check auth state changes
}//InitApp

И это HTML для формы:

<form id="formLogin" class="form-signin">
<h2 align="center" class="form-signin-heading">Inicia sessió</h2>
<label for="inputEmail" class="sr-only">Correu electrònic</label>
<input type="email" id="inputEmail" class="form-control" placeholder="Correu electrònic" required autofocus>
<label for="inputPassword" class="sr-only">Contrassenya</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Contrassenya" required>
<button id="btnLogin"class="btn btn-lg btn-primary btn-block" type="submit">Entrar</button>
</form>

Итак, в чем проблема? Если я использую этот код JS на консоли Chrome/Firefox, он входит в систему и работает.

EDITED: Как-то, если я сменю тег формы на div, он работает, но это бессмысленно. Есть ли проблема, связанная с использованием html5-форм с firebase?

Понравилась статья? Поделить с друзьями:
  • Sony a58 ошибка фотоаппарата
  • Sorry an unrecoverable error has been encountered zbrush will attempt to save the current
  • Sony a58 error рука
  • Sorry an unknown error occurred please try again later перевод
  • Sony a57 ошибка фотоаппарата