問題描述
Android:為沒有 Google Play 服務的用戶登錄 Google? (Android: Google signin for a user without Google Play Services?)
有沒有一種不需要 Google Play 服務即可實現 Google 登錄的方法?我知道官方文檔說您需要 GPS:
• https://developers.google.com/identity/sign‑in/android/start‑integrating
但是我在這裡也發現了相互矛盾的信息:
• 沒有 Google Play 服務的 Google Plus 登錄
這表示使用 Google+ Api 您可以在用戶沒有 GPS 的情況下實現登錄。哪個是真的?您是否可以在沒有 GPS 的情況下從技術上實現登錄?如果可以的話,它會很好地用作因任何原因無法下載 GPS 的用戶的後備。
參考解法
方法 1:
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:
- http://blog.doityourselfandroid.com/2011/08/06/oauth‑2‑0‑flow‑android/
- How do you obtain a oAuth2 token using webView in android?
- android OAuth‑2.0 google login for user info using webview
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)
(by Jon、Erik Zivkovic)