Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase signUpWithEmailAndPassword using Ionic

I am using the latest version of Ionic (v1.3.1) and Firebase (v3.1.0). I'm trying to do firebase user authentication using the following method:

firebase.auth().signInWithEmailAndPassword(email, password)

Whilst this method works perfectly when ionic is running in a web browser, when the ionic app is run natively on Android, it throws an error, specifically:

'A network error (such as timeout, interrupted connection or unreachable host) has occurred.'

I have made sure the app's config.xml allows access to all URLs so it doesn't appear to be an issue with Ionic.

Looking online, it seems that Firebase is possibly blocking the app's browser because it doesn't recognise the app's domain (domains for authentication appear to be whitelisted in the 'OAuth redirect domains' part of the authentication section in the Firebase dashboard).

However, there is not way to identify what an Ionic app's domain is (it certainly isn't 'localhost' or 127.0.0.1)

So, my question is: does Firebase signInWithEmailAndPassword(email, password) actually work with Ionic and other web-wrapper platforms, or is this currently unsupported?

like image 662
Steven Ellis Avatar asked Mar 07 '26 19:03

Steven Ellis


1 Answers

Make sure you are setting the correct Content-Security-Policy too. Something along:

<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *;script-src 'self' https://* 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https://* 'unsafe-inline' 'unsafe-eval'; ">

like image 113
bojeil Avatar answered Mar 10 '26 09:03

bojeil