angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

Runtime Error: A network error when login with facebook on web browser

Open bangive opened this issue 9 years ago • 44 comments

Version info

Ionic Framework: 2.0.0 Ionic Native: 2.4.1 Ionic App Scripts: 1.0.0 Angular Core: 2.2.1 Angular Compiler CLI: 2.2.1 Node: 6.9.5 OS Platform: Windows 7 Navigator Platform: Win32 User Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36

How to reproduce these conditions

I setup following this link https://github.com/angular/angularfire2/blob/master/docs/Auth-with-Ionic2.md

Debug output

Error: Uncaught (in promise): Error: A network error (such as timeout, interrupted connection or unreachable host) has occurred. at s (http://localhost:8100/build/polyfills.js:3:4211) at s (http://localhost:8100/build/polyfills.js:3:4034) at http://localhost:8100/build/polyfills.js:3:4574 at t.invokeTask (http://localhost:8100/build/polyfills.js:3:9723) at Object.onInvokeTask (http://localhost:8100/build/main.js:35843:37) at t.invokeTask (http://localhost:8100/build/polyfills.js:3:9659) at e.runTask (http://localhost:8100/build/polyfills.js:3:7083) at i (http://localhost:8100/build/polyfills.js:3:3671)

Actual behavior

The popup for facebook authentication is shown and disappeared shortly so i can't sign in.

Complete source code

https://drive.google.com/open?id=0B4dCHEToS7afNXM5WUN0ejlBMDA

bangive avatar Feb 04 '17 16:02 bangive

I am getting this error with Email/Password based authentication as well.

Is this thread related?

https://github.com/firebase/firebaseui-web/issues/98#issuecomment-275888728

These are my 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", "@types/lodash": "4.14.43", "angular2-moment": "^1.0.0", "angularfire2": "^2.0.0-beta.7.1-pre", "chart.js": "2.3.0", "es6-shim": "0.35.0", "ionic": "^2.2.1", "ionic-angular": "2.0.1", "ionic-native": "2.4.1", "ionic2-rating": "0.0.10", "ionicons": "3.0.0", "reflect-metadata": "^0.1.8", "rxjs": "^5.0.0-beta.12", "sw-toolbox": "3.4.0", "systemjs": "0.19.39", "typings": "^1.4.0", "whatwg-fetch": "^2.0.1", "zone.js": "^0.6.21"

chit786 avatar Feb 12 '17 14:02 chit786

Please make sure you enable xhr requests to https://www.googleapis.com. signInWithEmailAndPassword is just a simple request to that endpoint. Also make sure you are using the latest js version 3.6.9.

bojeil-google avatar Feb 13 '17 03:02 bojeil-google

@chit786 This issue is related to runtime error while authenticating with facebook. Are you getting a similar error. If not, then please open up a new issue using the issue template to provide more details about your environment.

On a different note, I don't see firebase module in your dependencies section above. Also, did you get a chance to look at the user authentication tutorial here.

mukesh51 avatar Feb 14 '17 21:02 mukesh51

@mukesh51 No I am getting exact same network error with email password login as well. Also regarding the firebase module in dependencies : i had to remove it since angularfire2 itself imports firebase and the cli compiler was throwing "duplicate import" errors. please correct me if I am missing something. I am using firebase API as well due to some requirement on offline data availability which angularfire2 library does not provide.

Also I felt the issue may be something related to the timeouts as described by bojeil hence I placed it here , so I wonder how to achieve the update in angulrfire2 installed package to try this out.

note : I am using firebase.initializeAPP cofiguration inside my compoenent.ts, like below:

firebase.initializeApp({ apiKey: "xxxxxxxxxxxxxxxxxxxxx", authDomain: "test.firebaseapp.com", databaseURL: "https://test.firebaseio.com", storageBucket: "test.appspot.com", messagingSenderId: "12345678901" },'app1');

and ,

firebase.auth().onAuthStateChanged function to check auth status of the user.

all the functionality works fine, both angularfire2 and firebase seem to work but after sometime this network error occurs.

lastly thank you for picking this up.

chit786 avatar Feb 15 '17 00:02 chit786

@chit786 Could you please share your repo.

mukesh51 avatar Feb 15 '17 09:02 mukesh51

@mukesh51 here you go. https://github.com/chit786/CAFFEIOT/tree/feature/chitrang-s_feature

chit786 avatar Feb 15 '17 10:02 chit786

also I check the firebase version and its 3.6.9 already. @bojeil-google i am not able to access https://www.googleapis.com. is this correct URL.

chit786 avatar Feb 15 '17 10:02 chit786

@chit786 i was able to download the repo and it worked successfully locally for me. After login into your app, I was able to see the coffee consumption dashboard page.

Do you have the correct user setup in your Firebase console. do you want to create a test user to see if its working.

mukesh51 avatar Feb 15 '17 15:02 mukesh51

I guess you need to logout and login again. Then pls wait for sometime, keep the wondow open, to reproduce it. Because I get error more frequently during logging in and logging out scenarios in pretty good network conditions.

chit786 avatar Feb 15 '17 15:02 chit786

Underneath the Firebase Auth backend has a domain https://www.googleapis.com. Make sure you are allowing requests to that domain. I haven't looked at your app code. For example, in some cases, there may be restrictions on outgoing requests in a Content-Security-Policy.

bojeil-google avatar Feb 15 '17 20:02 bojeil-google

@bojeil-google I verified this on real device and I can confirm that i am getting network error only with auth services, like login and sign up using email/password verification. I added the domain under OAuth redirect domains sections on firebase console but this error is still there.

@mukesh51 can you try couple of times login in and out and check it out on real devices?

Thank you all once again.

chit786 avatar Feb 16 '17 00:02 chit786

HI All, any updates on this request? ~Thanks

chit786 avatar Feb 18 '17 23:02 chit786

When I have had problems connecting to firebase auth in the past, it was always my workstation's security software. In my case, I use Bitdefender Total Security and if you disable Scan SSL under your Web Protection area for whatever security software you use. It took me a very long time and headache to discover this. Now if you do not have any security/malware running then I am not sure. Just trying to help.

jwuliger avatar Feb 19 '17 14:02 jwuliger

@chit786 It works fine for me. I tried running your app on android device and logged in and logged out at least 5 times in a span of 10 minutes. worked every time for me, although there was an error in the console (screen shot for your reference), but it still worked every time.

image

I was able to get rid of the error, by executing the following command in the project folder.

ionic plugin add phonegap-plugin-push --variable SENDER_ID=123456789

Let me know, how it goes at your end.

mukesh51 avatar Feb 26 '17 15:02 mukesh51

@mukesh51 Thank you for your response. can you please confirm on which android version did you try? I am trying on 4.4 Android since that is our minimum configuration support for the APP. Can you please confirm the same. Also on Web Chrome which chromium version do you have. mine is 56.0.2924.87 (64 bit).

I receive above mentioned issue ["Network error"] with the authentication and sign up API "on firebase.auth() " not sure but I am getting this a lot on 4.4 Android. If you have tried with the same version then may be its some issue in my configuration at which I am totally stuck at.

chit786 avatar Feb 26 '17 17:02 chit786

@chit786 I am on chrome version

Version 56.0.2924.87

and Android version on device is

5.0.2

Two quick suggestions

  1. Why not try to test your app on android version 5.
  2. Try creating the app from scratch, just to be doubly sure that while debugging you haven't changed two many configuration items.

mukesh51 avatar Feb 26 '17 18:02 mukesh51

Hi Mukesh I will try from scratch. Just to sure what is going wrong. Also just a point to add I have also tested on Android 6 nexus 6 and got same issue. So perhaps something may be wrong in configuration which is highly unlikely. Since It started throwing error after I upgraded to IONIC 2 final release.

chit786 avatar Feb 26 '17 18:02 chit786

Hi @mukesh51 ,

Today I tried again afresh by cloning my repo in another path ,and followed below steps , still I am getting the same issue, below example I carried out on my emulator

  1. cloned repo to a folder
  2. npm install
  3. typings install
  4. npm install firebase angularfire2 --save [using latest firebase and angularfire2]
  5. ionic state restore [reinstall all plugins and platforms]
  6. ionic platform add browser {Since I have the requirement of chrome extension as well}
  7. ionic run android --prod {Creating prod build}
screen shot 2017-02-27 at 20 35 52

my package.json now looks like :

{ "name": "XXXX", "author": "Chitrang Natu", "homepage": "http://ionicframework.com/", "private": true, "scripts": { "clean": "ionic-app-scripts clean", "build": "ionic-app-scripts build", "ionic:build": "ionic-app-scripts build", "ionic:serve": "ionic-app-scripts serve" }, "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", "@types/lodash": "4.14.43", "angular2-moment": "^1.0.0", "angularfire2": "^2.0.0-beta.8", "chart.js": "2.3.0", "es6-shim": "0.35.0", "firebase": "^3.6.10", "ionic": "^2.2.1", "ionic-angular": "2.0.1", "ionic-native": "2.4.1", "ionic2-rating": "0.0.10", "ionicons": "3.0.0", "reflect-metadata": "^0.1.8", "rxjs": "^5.0.0-beta.12", "sw-toolbox": "3.4.0", "systemjs": "0.19.39", "typings": "^1.4.0", "whatwg-fetch": "^2.0.1", "zone.js": "^0.6.21" }, "devDependencies": { "@ionic/app-scripts": "1.0.0", "@types/request": "0.0.30", "typescript": "2.0.9" }, "cordovaPlugins": [ "cordova-plugin-device", "cordova-plugin-console", "cordova-plugin-camera", "cordova-plugin-compat", "cordova-plugin-crop", "cordova-plugin-file", "cordova-sms-plugin", "cordova-plugin-whitelist", "cordova-plugin-splashscreen", "cordova-plugin-statusbar", "ionic-plugin-keyboard", { "variables": { "SENDER_ID": "XXXXXXXXXXX" }, "locator": "phonegap-plugin-push", "id": "phonegap-plugin-push" } ], "cordovaPlatforms": [ "ios", { "platform": "ios", "version": "", "locator": "ios" }, { "platform": "android", "version": "", "locator": "android" } ], "description": "Test" }

Please advice if i need to change something?

chit786 avatar Feb 27 '17 19:02 chit786

Closing due to inactivity and auth changes.

davideast avatar Mar 16 '17 11:03 davideast

i have just create new app and still see this problem. After a while I found out that i need to upload my app to firebase hosting. And then i can login with facebook successfully on localhost:8100. Be sure not to disable web oauth and client oauth in facebook developer page. Besure to add this in Valid OAuth redirect URIs field in facebook developer page: http://localhost:8100/__/auth/handler https://your-app.firebaseapp.com/__/auth/handler http://localhost:8000/__/auth/handler

I just cannot login with facebook on android. I logout facebook app and then login in my app. There is an error shown: App not setup: This app is still in development mode... Then i make app public (or add an tester) in Facebook App Review page. Then it works.

bangive avatar Mar 31 '17 02:03 bangive