angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

signInWithCredential error code auth/network-request-failed

Open uzumakinaruto123 opened this issue 10 years ago • 83 comments

Version info

Angular: 2.0.0-rc4

Ionic: 2.0.0-beta.35

Firebase: 3.3.0

AngularFire: 2.0.0-beta.2

Google plus sign in using signInWithCredential(idToken) .

var provider = (<any> firebase.auth.GoogleAuthProvider).credential(null,res.idToken);

     firebase.auth().signInWithCredential(provider)
      .then((success) => {
        this.navCtrl.setRoot(TabsPage);
        console.log("Firebase success: " + JSON.stringify(success));
      })
      .catch((error) => {
        this.error = error
        console.log("Firebase failure: " + JSON.stringify(error));
      });

Google sign is sucessfull and idToken is received. But , it gives 404 (Not Found) on https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyAssertion?key=<My-Api-Key> at firebase.auth().signInWithCredential() method.

Debug output

** Errors in the JavaScript console **

POST 
https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyAssertion?key=My-key 404 (Not Found)                                      zone.js:101

Firebase failure: {"code":"auth/network-request-failed","message":"A network error (such as timeout, interrupted connection or unreachable host) has occurred."}       app.bundle.js:254

Expected behavior

Should sign in into firebase using google sign in access token.

uzumakinaruto123 avatar Sep 30 '16 18:09 uzumakinaruto123

angularfire2 beta.7 requires rxjs ^5.0.1, however angular 2.2.1 beta 12 there are more mismatches with versioning that may produce some bugs

kleeb avatar Feb 09 '17 08:02 kleeb

I believe the root of the problem is that ionic-angular requires us to use v2.2.1. And if we want to update angularfire2 and firebase to a version that doesn't produce this bug it requires us to update rxjs. And if we update rxjs than angular v2.2.1 is not compatible. And since ionic-angular requires us to us v2.2.1 we can not update rxjs. So we have a circular problem that requires us to use older versions that will not solve this problem until ionic updates the version of angular that they are using. I have reached out to ionic and they have not responded with an update yet.

dcinadr avatar Feb 09 '17 18:02 dcinadr

Which is why i had to downgrade the version of firebase after i updated it to 3.6.9.

I just wonder why others are not responding to this issue since many should be facing this very problem!! and why was this issue closed?

satyagupta avatar Feb 10 '17 03:02 satyagupta

People that are experiencing it are probably just working around it since it is not a show stopper. You can use another browser or you can skip the message or you can load your dev tools after the app is loaded.

dcinadr avatar Feb 10 '17 04:02 dcinadr

Any code snippets would be very helpful @dcinadr we are stuck with this app where most of the part is ready but we cannot test on device :(

satyagupta avatar Feb 10 '17 04:02 satyagupta

Switching to rxjs >= 5 is not breaking anything. Npm is showing some dependency warnings, but not errors. Ionic team is fully aware of it, they are even using rxjs version 5 in the alpha version of the new ionic-native, so I guess the final release is a matter of time.

kleeb avatar Feb 10 '17 08:02 kleeb

Please, why does this issue keep getting closed? What is the resolution? I can create a Firebase account with email/password in Firefox, but not with Chrome (Dev Tools off). Just straight up web, not Ionic. @dcinadr what is the work around you refer to? I do not have DevTools open in Chrome and get the network error. I'm using the code straight out of the documentation:

this.auth.createUserWithEmailAndPassword(email, password).catch(function(error) { // Handle Errors here. var errorCode = error.code; var errorMessage = error.message; // ... console.log("createUserWithEmailAndPassword errorCode: " + errorCode); console.log("createUserWithEmailAndPassword errorMessage: " + errorMessage); });

ERROR: createUserWithEmailAndPassword errorCode: auth/network-request-failed createUserWithEmailAndPassword errorMessage: A network error (such as timeout, interrupted connection or unreachable host) has occurred.

Qyoom avatar Feb 21 '17 23:02 Qyoom

@Qyoom - please refer to my previous post for my workarounds. However, you are running a command that I am not running yet. So it is possible that my workaround will not work for you. And I may run into the same problem you are experiencing once i use that command.

dcinadr avatar Feb 22 '17 18:02 dcinadr

Hi everyone !

I have this problem with Ionic 2 on Android Phones below KitKat (<4.4), even with crosswalk plugin installed. I use theses versions :

Ionic 2.1.0 Angular 2.2.1 (this version is mandatory for Ionic 2.1.0) Rxjs 5.0.1 or 5.0.0-beta.12 (both tested) angularfire2 2.0.0-beta.7-pre or 2.0.0-beta.8 (both tested)

If anyone have a clue on how to fix this, that would be greatly appreciated ! :-)

nilebma avatar Mar 01 '17 12:03 nilebma

Fixed using firebase 3.6.1 with an ionic project with this configuration Ionic CLI Version: 2.1.13 Ionic App Lib Version: 2.1.7

AlvaroHerrero avatar Mar 17 '17 15:03 AlvaroHerrero

Could someone from the Ionic or AngularFire team please show some direction - perhaps publish the package.json that has been verified to work with the latest versions of AngularFire2+Ionic2. If this could be done every time you put out a new version, it would save so many people so much time and pain. I have spent the past week trying to move to Ionic 2.2, the email authentication stopped working on Android. What is wrong with this ?

"dependencies": { "@angular/common": "2.4.8", "@angular/compiler": "2.4.8", "@angular/compiler-cli": "2.4.8", "@angular/core": "2.4.8", "@angular/forms": "2.4.8", "@angular/http": "2.4.8", "@angular/platform-browser": "2.4.8", "@angular/platform-browser-dynamic": "2.4.8", "@angular/platform-server": "2.4.8", "@ionic-native/core": "3.1.0", "@ionic-native/splash-screen": "3.1.0", "@ionic-native/status-bar": "3.1.0", "@ionic/storage": "2.0.0", "angularfire2": "^2.0.0-beta.8", "firebase": "3.7.3", "ionic-angular": "2.3.0", "ionicons": "3.0.0", "rxjs": "5.0.1", "sw-toolbox": "3.4.0", "zone.js": "0.7.2" }, "devDependencies": { "@ionic/app-scripts": "1.2.2", "typescript": "~2.2.1" }, "cordovaPlugins": [ "cordova-plugin-whitelist", "cordova-plugin-console", "cordova-plugin-device", "cordova-plugin-statusbar", "cordova-plugin-splashscreen", "ionic-plugin-keyboard" ], (I also tried the different firebase version like 3.6.1...)

dovk avatar Mar 28 '17 19:03 dovk

changing the type in my button tag to type="button" instead of type="submit" solved this problem for me.

patel1jr avatar Apr 05 '17 00:04 patel1jr

Thanks for sharing your solutions @patel1jr and @AlvaroHerrero . Unfortunately, none of them works on my side. I tried every updates since I encounter the problem more than a month ago, but it persists : impossible to log or signup users on Android < 4.4 ... :-/

nilebma avatar Apr 05 '17 07:04 nilebma

Of all of the suggestions above, the one thing that worked eventually was using "firebase": "3.3.0" instead of "firebase": "3.7.3" in package.json (enclosed a few posts before). I'm using a very basic login based on an example from Jorge Vergara https://javebratt.com/angularfire2-authentication-ionic/

I just wanted to use simple email/password login for now - I hope adding Facebook and others will eventually work as well. Too bad this is the current situation - Good Luck to us all!

dovk avatar Apr 05 '17 09:04 dovk

I solved this problem by entering the manifest.xml file and putting this line

<uses-permission android: name = "android.permission.INTERNET" />

wilsoncx avatar Apr 06 '17 02:04 wilsoncx

I'm facing the same issue building Ionic2/AngularFire2 app and also with Ionic2/Firebase sdk. It works fine with serve on chrome and firefox but issue occurs with run on browser or android (i.e. ionic run android) or run using cordova is essentially the same. Therefore, it seems like its an issue with cordova and firebase.

Those are my dependencies: [email protected] [email protected] angularfire2 @2.0.0-beta.7-pre [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]

Thanks to the folks here, I was able to fix it by downgrading to [email protected] and now its working fine on android.

AbdullahAdeeb avatar Apr 09 '17 04:04 AbdullahAdeeb

I feel that the most stable Firebase version with angularfire2 beta8 is 3.4.0

kleeb avatar Apr 09 '17 10:04 kleeb

I have meanwhile moved up to Ionic3/Angular4 and all is well except for having to keep Firebase at 3.3.0 (I tried [email protected] as mentioned above but it did not work). You can see my package.json here https://github.com/dovk/ionic3-calendar (and if anyone is looking for a simple Calendar/Datepicker - feel free to use it)

dovk avatar Apr 09 '17 11:04 dovk

+1 for rolling back to Firebase 3.3.0. I've been having a problem with intermittent connections to Firebase on Android devices. But rolling back seems to have resolved the issue.

lawlesscreation avatar Apr 14 '17 20:04 lawlesscreation

downgrade from 3.7.5 to 3.3.0 works for me.

gammafilho avatar Apr 18 '17 14:04 gammafilho