5

Is there a way of implementing Google signin that does not require Google Play Services? I'm aware that the official docs says that you need GPS:

https://developers.google.com/identity/sign-in/android/start-integrating

however I also found conflicting information here:

Google Plus Login without Google Play Services

that says that using Google+ Api you can implement the login without the user having GPS. Which is true? Can you technically implement login without GPS or not? If you can it would be nice to use as a fallback for users who can't download GPS for whatever reason.

Community
  • 1
  • 1
Jon
  • 7,941
  • 9
  • 53
  • 105

1 Answers1

4

You can use the Android Account Manager to get an access token (if the user has signed in with his/her Google Account on the phone):

If that is not what you want, you can always sign a user in using pure OAuth2 through a WebView. Here are some resources to get you started:

If you choose to use a webview you will have to handle access/refresh tokens manually, which might or might not be convenient for you.

Good Luck!

Edit: You mentioned G+ in your post, so here is some information on how to add G+ scopes to your request:

(Choose a scope that you need and include it in your request for access/refresh token)

Community
  • 1
  • 1
Erik Živković
  • 4,867
  • 2
  • 35
  • 53
  • Many thanks for your reply! Question regarding the first doc that you referenced. It states: "To get started with GoogleAuthUtil for accessing Google's REST APIs, you must set up your Android app project with the Google Play services library." Doesn't this mean that this requires that the user should have GPS on their device in order for this to work? It also throws a GooglePlayServicesAvailabilityException which seems to confirm this. – Jon Dec 07 '15 at 13:20
  • 1
    You are right, sorry about that! This method in the account manager should give you a valid auth token http://developer.android.com/reference/android/accounts/AccountManager.html#getAuthToken(android.accounts.Account,%20java.lang.String,%20android.os.Bundle,%20android.app.Activity,%20android.accounts.AccountManagerCallback,%20android.os.Handler) but I'm not sure how to exchange it for an access token (if you need that) – Erik Živković Dec 07 '15 at 13:40
  • Using webview won't work anymore, according to [this blog post from Google](https://developers.googleblog.com/2021/06/upcoming-security-changes-to-googles-oauth-2.0-authorization-endpoint.html) – Maciej Witowski Oct 13 '21 at 12:01
  • The provided web view solution worked just fine with minor changes! @MaciejWitowski it works for me though. – Jaswant Singh May 17 '22 at 07:49