An alternative to using webview for oAuth Google without enabling the Google Play service

We have custom devices that run on the Android OS, but do not have built-in Google Play services. We have a Google login using Webview Oauth2.0 authentication. And according to the documentation, it was changed.
I read that there is a method https://developers.google.com/identity/sign-in/android/ , but it looks like gradle is required to include it. So how can I use google authentication?
I found 2 options as shown below, but will they be useful 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

What may be the most suitable for my requirement
Please, help.
Yours faithfully,
Sraddha

+6
source share
1 answer

Yes, indeed, Google quite a long time ago blocked the ability to access services through the internal WebView application. The reason is that Google does not trust external application providers that are not aware of connection security. This forces third-party application providers to use Google’s login methods for their services.

Source: Modernizing OAuth interactions in native applications to improve usability and security.

Indeed, you have found the right ways to use Google services, however Firebase and Google Sign In have a flaw that makes them unusable for you, namely both need Google Play services. Firebase needs them, and Google Sign-in needs them . Thus, there is no official way to use both on devices that do not have Google Play services.

There is another way: Chrome custom tabs . However, they do require Chrome installed on the device. And for a long time it also uses Google Play services . Moreover, Chrome custom tabs were introduced later than Chrome turned on Google Play services.

However, there is a hack. Declare the internal user agent of the WebView application as Chrome. Here is the documentation . As you can see at the bottom of this page, you can remove the following lines from the WebView of the WebView user agent:

  • Version/_X.X_ on Version/_X.X_
  • wv on Lollipop + devices.

However, I do not recommend this method and please adhere to Google’s policy, if possible.

Hope this explanation is enough.

EDIT: According to the comment below, the Goole Api Java client does not need Google Play Services, so this may be an option.

+5
source

Source: https://habr.com/ru/post/1270188/


All Articles