Firebase Oauth在第三方应用程序的Web视图上禁止用户代理 [英] Firebase Oauth disallowed user agent on third party app's web view

查看:1066
本文介绍了Firebase Oauth在第三方应用程序的Web视图上禁止用户代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用OAuth身份验证。事情是OAuth身份验证在正常的浏览器上正常工作,但它不适用于第三方应用程序的Web视图,如LINE或Facebook的Messenger。第三方应用程序的网页视图发生了什么,当用户点击用Google登录时,Google会显示错误页面403错误:disallowed_useragent。 (当我尝试通过Messenger将链接发送到我的Web应用程序时,会发生这种情况,当我的朋友点击链接时,Messenger在他们的Web视图中打开我的Web应用程序,我的朋友将无法点击登录那么)

因此,我做了一些搜索,发现Google已经通过Web视图弃用了OAuth身份验证。以下是 LINK



所以我的问题是:
如果检测到Web视图,是否可以强制用户打开正常的浏览器?
或者有什么办法可以解决这个问题?



我正在使用Firebase身份验证。我的所有代码都使用Firebase SDK进行身份验证firebase-auth.js和firebase.js) 解决方案

和iframes,它允许safari webkit.if你用safari用户代理覆盖用户代理,那么它将工作。
试试这个,一旦它可以正常工作

  webView.getSettings()。setUserAgentString(Mozilla / 5.0(Windows NT 6.1 )AppleWebKit / 537.36(KHTML,像Gecko)Chrome / 41.0.2228.0 Safari / 537.36); 


I am having trouble with OAuth authentication. The thing is the OAuth authentication works properly on normal browser, but it doesn't work on third party app's web view such as LINE or Facebook's Messenger. What happen is on third party app's web view, when user click "sign in with google", for instant, Google will show error page 403 error: "disallowed_useragent". (This happens when I try to send the link to my web application to my friend via the Messenger. When my friend click on the link, Messenger open my web application on their web view. My friend won't be able to click sign in then)

Therefore, I do some searches and found out that Google has deprecated OAuth authentication via the web view. Here is the LINK.

So my questions is: Is it possible to force user to open normal browser if web view is detected? Or are there some ways to work around with this?

I am using Firebase authentication for this. All of my codes use Firebase SDK for authentication firebase-auth.js and firebase.js)

解决方案

Google restricts the authentication from webviews and iframes,it allowes safari webkit.if you override user agent with safari user agent then it will works. try this once it will works

    webView.getSettings().setUserAgentString("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");

这篇关于Firebase Oauth在第三方应用程序的Web视图上禁止用户代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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