Firebase + Ionic3错误:disallowed_useragent [英] Firebase + Ionic3 Error: disallowed_useragent

查看:141
本文介绍了Firebase + Ionic3错误:disallowed_useragent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于此主题<,但是他们没有将Firebase与Ionic一起使用.我刚刚切换到新的Ionic View,现在,在旧的Ionic View中,我的应用程序正常工作,而新的Ionic View给了我这个众所周知的错误:

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错误-那是一个错误.错误:disallowed_useragent他的用户代理 不允许以以下身份向Google发出OAuth授权请求: 它被归类为嵌入式用户代理(也称为网络视图). 等等等等

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

在我的代码中,我注入了Firebase AuthProvider并使用angularfire2进行连接,看起来像

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))
. . .

同样,这在浏览器或旧的Ionic中效果很好,但不适用于新的Ionic View.我确实有一个很大的具有常规OAuth连接的库,但是我认为使用Firebase的重要原因之一是我们将不再需要使用这些库并自行管理用户.

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.

是否可以通过Ionic在iOS/Android应用上进行Firebase身份验证?

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

推荐答案

您应遵循

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

我通过在config.xml中添加以下内容来解决了disallowed_useragent错误:

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

<preference name="OverrideUserAgent" value="Mozilla/5.0 Google" />

这篇关于Firebase + Ionic3错误:disallowed_useragent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆