android - 如何从 Firebase 上的本机移动应用程序登录到 Web 应用程序
问题描述
我有一个使用 firebase auth 的网站。
我也使用 firebase auth sdk 开发原生移动应用程序(android、iOS 或 Unity)。
用户在移动应用程序上通过身份验证后,我将打开一个 web 视图,以便用户可以使用我的网站。如何使用他们在移动应用程序中提供的凭据让用户登录到 webview?
解决方案
如果您想在每个 webview 请求中发送授权令牌,您应该像这样覆盖 WebViewClient 中的 onReceivedHttpAuthRequest 方法。
webView.webViewClient = object : WebViewClient() {
override fun onReceivedHttpAuthRequest(view: WebView?, handler: HttpAuthHandler?, host: String?, realm: String?) {
handler?.proceed("token_auth", "authtoken_here")
}
}
推荐阅读
- python - 有没有办法提高生成随机 xy 坐标的算法的效率?
- kubernetes - Azure Kubernetes 服务连接无法验证
- unit-testing - Springboot,Powermockito,未能模拟静态方法
- r - 如何在 R 中制作 S3 通用绘图功能?
- c# - WPF 图像集合到 ListView 而不使用文件路径
- python - 如何在 Kivy 中运行 Selenium(浏览器在 Kivy 窗口中打开)
- regex - PowerShell - 替换为在该行中彼此相邻的多个匹配项
- mysql - 为每个员工选择一天中时间戳最早的完整记录
- windows - 如何使用用户列表编写带有 For 循环的 Powershell 脚本以打印出 Active Directory 信息
- docusignapi - 清除信封前的 Webhook 警告