在未合并Google Play服务的情况下将Webview用于oAuth Google的替代方法 [英] Alternative for using webview for oAuth Google without Google Play service incorporation

查看:96
本文介绍了在未合并Google Play服务的情况下将Webview用于oAuth Google的替代方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有可在Android操作系统上运行的自定义设备,但未集成Google Play服务.
我们使用Webview Oauth2.0身份验证进行Google登录.并且根据文档,它已被弃用.
我了解到有一种方法 https://developers.google.com/identity/sign-in/android/,但这似乎需要结合gradle才能提供播放服务.
那么我可以使用哪种方式进行Google身份验证?
我发现了以下两个选项,但它们对我的情况有帮助吗?
1. https://firebase.google.com/docs/auth/android/start/
2. https://developers.google.com/api-client-library/java/google-api-java-client/oauth2

We have custom devices which run on Android OS but dont have Google Play services incorporated.
We have Google login using Webview Oauth2.0 authentication. And as per the documentation it has been deprected.
I read that there is a way https://developers.google.com/identity/sign-in/android/ but this seems that it requires gradle incorporation for play services.
So which way could I use for google authentication?
I found 2 options as below but will they be helpful in my case?
1. https://firebase.google.com/docs/auth/android/start/
2. https://developers.google.com/api-client-library/java/google-api-java-client/oauth2

哪一个最适合我的需求?
请帮忙.
问候,
Shraddha

Which can be the most suitable for my requirement
Please help.
Regards,
Shraddha

推荐答案

是的,确实,谷歌早在一段时间之前就已经阻止了通过应用程序内部的 WebView 登录到其服务的可能性.原因是Google不信任外部应用程序提供商,因为它不知道连接的安全性.它迫使外部应用程序提供商使用Google的服务登录方法.

Yes, indeed google quite some time ago has blocked the possibility to login to it's services via app's internal WebView. The reason is that Google does not trust external app providers, where it is't aware of security of connection. It forces external app providers to use Google's methods of login to it's services.

来源:在本机应用程序中现代化OAuth交互以获得更好的可用性和安全性

实际上,您已经找到了使用Google服务的正确方法,但是 Firebase Google登录的缺点是您无法使用它们,即都需要 Google Play服务. Firebase需要它们

Indeed you have found the right methods to use Google services, however, Firebase and Google Sign In have disadvantage that makes them unusable by you, namely both need Google Play Services. Firebase needs them and Google Sign-in needs them. So there is no official way of using both on devices not having Google Play Services.

还有另一种方法: Chrome自定义标签.但是,它们要求在设备上安装Chrome.长期以来,它也使用Google Play服务.此外,在Chrome合并了 Google Play服务

There is yet another way: Chrome Custom Tabs. However, they require Chrome installed on the device. And since a long time it also uses Google Play Services. Moreover, Chrome Custom Tabs have been introduced later than Chrome has incorporated Google Play Services

但是,有一个hack.将应用程序的内部WebView的用户代理声明为Chrome.这是文档.如本页底部所示,您可以从 WebView 用户代理字符串中删除以下字符串:

However, there's a hack. Declare app's internal WebView's User Agent as Chrome. Here is the documentation. As seen at the bottom of this page, you could remove following Strings from WebView User Agent String:

    Kitkat设备上的
  • 版本/_X.X _
  • Lollipop +设备上的
  • wv .
  • Version/_X.X_ on Kitkat Devices
  • wv on Lollipop+ devices.

但是,我不建议您使用这种方法,如果可能的话,我鼓励您遵循Google政策.

However, I do not recommend this method and kindly encourage to stick to Google Policy, if there is a possibility.

希望这种解释就足够了.

Hope that this explanation is enough.

根据下面的评论, Goole Api Java客户端不需要 Google Play服务,因此可以选择.

As per comment below, Goole Api Java Client does not need Google Play Services, so this might be an option.

这篇关于在未合并Google Play服务的情况下将Webview用于oAuth Google的替代方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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