Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative for using webview for oAuth Google without Google Play service incorporation

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

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

like image 481
Shraddha Shravagi Avatar asked Jul 25 '17 10:07

Shraddha Shravagi


People also ask

Is OAuth Google free?

It is not free.


1 Answers

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.

Source: Modernizing OAuth interactions in Native Apps for Better Usability and Security

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.

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

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:

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

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.

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

like image 189
R. Zagórski Avatar answered Oct 21 '22 07:10

R. Zagórski