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

For anyone using firebase and phonegap/cordova, I ran into the same issue.

Using firebase version 3.6.1 fixed the issue for me.

apatton724 avatar Jan 15 '17 16:01 apatton724

This happens for me too on Chrome, even if I'm using 3.6.1 of firebase. However, it works on firefox

zwhitchcox avatar Jan 17 '17 19:01 zwhitchcox

@dcinadr I don't think it has to do with angularfire, it has to do with firebase itself. I'm using react and still getting the error.

zwhitchcox avatar Jan 17 '17 19:01 zwhitchcox

[redacted]

zwhitchcox avatar Jan 17 '17 19:01 zwhitchcox

We do love feedback, and appreciate it. But please keep it civil, constructive and on topic.

katowulf avatar Jan 17 '17 19:01 katowulf

@apatton724 I can confirm this. I use angular#1.5.8 ionic#1.3.2 firebase#3.6.1 angularfire#2.3.0

with firebase#3.6.6, when using $firebaseAuth().$signInWithCustomToken on and Android app (6.0 and 4.4) I get the "auth/network request failed even though I have already logged a connection info to the firebase db. This does NOT happen in a browser, or on iOS (same app) only Android app. There seem to be something wrong with the timing of sign-in of firebaseAuth.

if you watch $firebaseAuth.$onAuthStateChanged you will see it fires twice when you use $firebaseAuth().$signInWithCustomToken. Once without a firebaseUser and once with the actual signed in user. (Ver 3.6.1) In ver 3.6.5 and 3.6.6, and 3.6.7 the 2nd $onAuthStateChanged does NOT fire (because the signInWithCustomToken does not complete)

gerhardcit avatar Jan 25 '17 06:01 gerhardcit

Can you reproduce the same behavior without AngularFire, by dropping to the Firebase SDK and running auth?

katowulf avatar Jan 25 '17 16:01 katowulf

also have the same issue, i tried this following :

  • add cordova-whitelist-plugin
  • check meta content-security-policy
  • remove "form" balise, to avoid ng-submit

using : ionic#1.3.1 firebase#3.6.6

whispyy avatar Jan 30 '17 18:01 whispyy

why was it closed? there are many still facing the same issue. It works only 20% else it would keep showing network error.

satyagupta avatar Feb 06 '17 09:02 satyagupta

Checked up on this today with the auth team and they pointed out this interesting fix in the 3.6.8 release:

image

Could someone test this out and verify that it's fixed in 3.6.8 of the Firebase SDK? I think that will resolve many of the reports here.

katowulf avatar Feb 08 '17 02:02 katowulf

@katowulf update firebase to latest 3.6.9 and still facing the same issue :(

satyagupta avatar Feb 08 '17 04:02 satyagupta

@satyagupta is correct. It still does not work. I am using it with Ionic2 which requires angular 2.2.1. This requires me to use angularfire2 no later than v2.0.0-beta.6. I am not sure if this causes an issue. Cause I have another project that uses the latest angularfire2 and the latest angular (not an ionic project) and there is no problems on that project.

dcinadr avatar Feb 08 '17 05:02 dcinadr

@dcinadr can you share the version/specs of other project where it works? i ahve been trying a lot of things but its does not fix it.

satyagupta avatar Feb 08 '17 07:02 satyagupta

For the "does not work" replies, please open a new issue, with more specific errors/stacks/details and minimal repros, as well as networking logs. To move this forward, we'll need to build a strong case here showing that this is an issue in the SDK and not related to the many other moving parts in an Ionic build.

katowulf avatar Feb 08 '17 18:02 katowulf

@satyagupta - here are my dependencies

"dependencies": {
    "@angular/common": "2.4.3",
    "@angular/compiler": "2.4.3",
    "@angular/core": "2.4.3",
    "@angular/forms": "2.4.3",
    "@angular/http": "2.4.3",
    "@angular/platform-browser": "2.4.3",
    "@angular/platform-browser-dynamic": "2.4.3",
    "@angular/router": "3.4.3",
    "@angular/upgrade": "2.4.3",
    "@types/lodash": "4.14.50",
    "angular-calendar": "0.6.2",
    "angular2-datatable": "0.5.2",
    "angular2-ladda": "^1.0.6",
    "angular2-toaster": "2.0.0",
    "angularfire2": "2.0.0-beta.7",
    "chart.js": "^2.3.0",
    "core-js": "^2.4.0",
    "dragula": "^3.7.2",
    "firebase": "^3.6.9",
    "moment": "2.17.1",
    "ng2-bootstrap": "^1.2.5",
    "ng2-charts": "^1.5.0",
    "ng2-dragula": "^1.3.0",
    "ng2-select": "^1.2.0",
    "rxjs": "5.0.3",
    "ts-helpers": "^1.1.2",
    "zone.js": "0.7.6"
  },
  "devDependencies": {
    "@types/jasmine": "^2.5.41",
    "angular-cli": "1.0.0-beta.25.5",
    "codelyzer": "2.0.0-beta.4",
    "extract-text-webpack-plugin": "^2.0.0-rc.0",
    "gulp": "^3.9.1",
    "gulp-sass": "^3.1.0",
    "jasmine-core": "^2.5.2",
    "jasmine-spec-reporter": "3.2.0",
    "karma": "1.4.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-jasmine": "^1.1.0",
    "karma-remap-istanbul": "^0.4.0",
    "protractor": "5.0.0",
    "ts-node": "2.0.0",
    "tslint": "4.3.1",
    "typescript": "2.1.5"
  }

dcinadr avatar Feb 09 '17 03:02 dcinadr

"dependencies": { "@angular/common": "2.2.1", "@angular/compiler": "2.2.1", "@angular/compiler-cli": "2.2.1", "@angular/core": "2.2.1", "@angular/forms": "2.2.1", "@angular/http": "2.2.1", "@angular/platform-browser": "2.2.1", "@angular/platform-browser-dynamic": "2.2.1", "@angular/platform-server": "2.2.1", "@ionic/storage": "^1.1.7", "angularfire2": "^2.0.0-beta.7", "autolinker": "^1.4.0", "crypto-js": "^3.1.9-1", "firebase": "^3.6.6", "font-awesome": "^4.7.0", "ionic-angular": "2.0.0-rc.5", "ionic-native": "2.2.11", "ionicons": "3.0.0", "localforage": "^1.4.3", "rxjs": "^5.0.0-beta.12", "sw-toolbox": "3.4.0", "typescript": "^2.0.0", "zone.js": "0.6.26" }, "devDependencies": { "@ionic/app-scripts": "1.0.0", "typescript": "2.0.9" }

here is mine, i had to down grade the firebase and angular fire to make it work.

BTW i keep getting error that Angular needs rxjs 5.0.0 if i do npm update

satyagupta avatar Feb 09 '17 05:02 satyagupta

@satyagupta - i believe the problem is with ionic2. It doesn't support the latest version of angular. thats why this project works for me. Because it is not an ionic project. When I use it my ionic project i am getting the same problems as you.

dcinadr avatar Feb 09 '17 05:02 dcinadr

oh k so you are using it as a AngularProject right?

satyagupta avatar Feb 09 '17 05:02 satyagupta

@katowulf check dependencies posted by @dcinadr above. That project does not even include ionic.

Debug output has been included in the OP (by me). That is complete js error that is thrown everytime.

Maybe I will post again ,

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

What can be more specific ? I will post if I can

Thanks

uzumakinaruto123 avatar Feb 09 '17 06:02 uzumakinaruto123

@uzumakinaruto123 bro create a new ticket with same details.

And i confirm the same issue that we face too. verifyPassword works but then the next request does not goes through and same error throws.

satyagupta avatar Feb 09 '17 06:02 satyagupta