gpt4 book ai didi

angular - Firebase + Ionic3 错误 : disallowed_useragent

转载 作者:太空狗 更新时间:2023-10-29 17:28:01 27 4
gpt4 key购买 nike

关于 this topic 还有一些其他问题/答案,但他们没有将 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

在我的代码中,我注入(inject)了 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 身份验证?

最佳答案

您应该按照 this article 中的说明进行操作.我认为 signInWithPopup 方法不受支持,您应该尝试 signInWithRedirect 代替。

我通过将以下内容添加到我的 config.xml 来修复 disallowed_useragent 错误:

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

关于angular - Firebase + Ionic3 错误 : disallowed_useragent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47237896/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com