Firebase + Ionic3 Error: disallowed_useragent
Firebase + Ionic3 Error: disallowed_useragent
this topic 上还有一些其他 questions/answers,但他们没有将 Firebase 与 Ionic 一起使用。我刚刚切换到新的 Ionic View,今天,我的应用程序在旧的 Ionic View 中工作,而新的 Ionic View 给我这个众所周知的错误:
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 进行连接,看起来像
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 的一个重要原因是我们将不再需要使用这些库和自己管理用户。
有没有办法通过 Ionic 在 iOS/Android 应用程序上进行 Firebase 身份验证?
我强烈建议您 运行 在 真实设备上使用此功能 因为 Ionic View 应用程序在原生插件等方面存在很多问题
CLI
ionic cordova run android --prod --device
或
ionic cordova run ios --prod --device
试试这个
ionic cordova build android --minifycss --optimizejs --minifyjs
帮我解决了
您应该按照 this article 中的说明进行操作。我认为 signInWithPopup
方法不受支持,您应该尝试 signInWithRedirect
代替。
我通过将以下内容添加到我的 config.xml
来修复 disallowed_useragent
错误:
<preference name="OverrideUserAgent" value="Mozilla/5.0 Google" />
this topic 上还有一些其他 questions/answers,但他们没有将 Firebase 与 Ionic 一起使用。我刚刚切换到新的 Ionic View,今天,我的应用程序在旧的 Ionic View 中工作,而新的 Ionic View 给我这个众所周知的错误:
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 进行连接,看起来像
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 的一个重要原因是我们将不再需要使用这些库和自己管理用户。
有没有办法通过 Ionic 在 iOS/Android 应用程序上进行 Firebase 身份验证?
我强烈建议您 运行 在 真实设备上使用此功能 因为 Ionic View 应用程序在原生插件等方面存在很多问题
CLI
ionic cordova run android --prod --device
或
ionic cordova run ios --prod --device
试试这个
ionic cordova build android --minifycss --optimizejs --minifyjs
帮我解决了
您应该按照 this article 中的说明进行操作。我认为 signInWithPopup
方法不受支持,您应该尝试 signInWithRedirect
代替。
我通过将以下内容添加到我的 config.xml
来修复 disallowed_useragent
错误:
<preference name="OverrideUserAgent" value="Mozilla/5.0 Google" />