Easy OAuth2 with Google explained
Here is the different steps to get a valid Access Token to query Google apis, manually.
Note that we should always use a proper library to do that automatically behind the scene (because it has to handle the refresh token route too).
https://console.developers.google.com
http://example.com/oauth2callback
. Google needs this to ensure it's talking to you.https://accounts.google.com/o/oauth2/auth?
client_id=424006053408-t3v4em804rcso.apps.googleusercontent.com
&redirect_uri=http://example.com/oauth2callback
&response_type=code
&scope=email
email
is implicitly replaced by https://www.googleapis.com/auth/userinfo.email
.https://www.googleapis.com/auth/plus.login
to grab the google plus profile data for instancehttp://example.com/oauth2callback?code=4/wKwdfCSuWD0tK5A-krKbWS7_ToA#
https://accounts.google.com/o/oauth2/token
client_id=424006053408-t3v4emgkqi6rcso.apps.googleusercontent.com
&code=4%2FjDREzDtWEPtZELmonN1oZpCNU
&client_secret=wDOY-Lj5bggktWNCa
&grant_type=authorization_code
&redirect_uri=http%3A%2F%2Fexample.com%2Foauth2callback
access_token
, id_token
, and expires_in
{
"access_token": "ya29.GltDFHu_0D1940sHXMF2yvLgFvKxqj0z_s1S1llGRd...",
"expires_in": 3600,
"id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6ImJ...",
"token_type": "Bearer"
}
https://www.googleapis.com/oauth2/v2/userinfo
returns some json with id
, email
and so on (if scope was email
)https://www.googleapis.com/plus/v1/people/me
returns google plus data (if scope was plus.login
)