7

There are a couple of other questions/answers on this topic, but they were not using Firebase with Ionic. I just switched to the new Ionic View and right now today, my app in the old Ionic View works while the new Ionic View gives me this well known error:

403 Error - Thats an error. Error: disallowed_useragent his user-agent is not permitted to make an OAuth authorization request to Google as it is classified as an embedded user-agent (also known as a web-view). blah blah blah

In my code I inject the Firebase AuthProvider and use angularfire2 to connect and it looks like

  private getProvider(from: string): AuthProvider {
  switch (from) {
    case 'twitter': return new firebase.auth.TwitterAuthProvider();
    case 'facebook': return new firebase.auth.FacebookAuthProvider();
    case 'github': return new firebase.auth.GithubAuthProvider();
    case 'google': return new firebase.auth.GoogleAuthProvider();
  }
}

  signIn(from: string) {
    this.afAuth.auth.signInWithPopup(this.getProvider(from))
. . .

Again, this works great in the browser or old Ionic but not the new Ionic View. I do have a fairly big library with general OAuth connections, but I thought that one of the great reasons to use Firebase is that we would no longer have to use those libraries and manage users ourselves.

Is there a way to do the Firebase auth on an iOS/Android app via Ionic?

Sampath
  • 63,341
  • 64
  • 307
  • 441
John
  • 223
  • 3
  • 13

3 Answers3

7

You should follow the instructions in this article. I don't think signInWithPopup method is supported, you should try signInWithRedirect instead.

I managed to fix the disallowed_useragent error by adding the following to my config.xml:

<preference name="OverrideUserAgent" value="Mozilla/5.0 Google" />
Paul Siersma
  • 2,036
  • 1
  • 22
  • 25
  • 1
    Only problem is that now, platform will be detected as desktop. Presents a small problem for me, but you solved a huge one and I can now finally login with Google on Cordova. Thank you, thank you, thank you. – Enric Ribas Jun 21 '20 at 20:37
1

try this

ionic cordova build android --minifycss --optimizejs --minifyjs

solved for me

Bang Benu
  • 11
  • 2
0

I highly suggest you to run this on the real device since Ionic view app has a lot of issues with native plugins and etc.

CLI

ionic cordova run android --prod --device

or

ionic cordova run ios --prod --device
Sampath
  • 63,341
  • 64
  • 307
  • 441