简体   繁体   中英

Android - Google login with OAuth 2.0

In Android's sample app (that's provided with google play services) for google login, they are using this SCOPE - "oauth2: https://www.googleapis.com/auth/userinfo.profile " and this end point - " https://www.googleapis.com/oauth2/v1/userinfo?access_token= "

While I was implementing it I came across this document which (I think) states that this scope/endpoint is depricated:

Important: Google has deprecated the early implementation of OAuth 2.0 for login that is described in this document but will maintain it and keep it available for backward compatibility. If your app uses OAuth 2.0 login (early version), you might consider either switching to Google+ Sign-In or changing your existing userinfo endpoints and scopes as described in migration timetable. For instructions, see Migrate or update OAuth 2.0 login.

Since I don't want to limit my audience to Google+ users, I want to update the OAuth 2.0 login, but I don't know how to do that. I completely lost in google api documentations. I saw this endpoint somewhere - https://www.googleapis.com/plus/v1/people/me but don't know how to use it and if I should change the scope.. And I also didn't understand if it is a regular google login or google+ login (since it has the word "plus" in the path..).

I need an updated example/tutorial for google login.

Google+ Signin does use OAuth 2.0. I believe by OAuth 2.0 Login, you are referring to Open ID Connect . That link includes sample code as well as an strong overview on the whole OAuth flow.

Google+ Signin is still a perfectly valid option of authentication though. Signin works for any Google account, whether or not you use Google+ does not matter (unless you actually need Google+ user information). It's also, possibly, the easiest way to implement OAuth, as you can get away with just integrating the button (using the code provided) and it will suffice for most applications.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM