i.e. making the user prove their identity
Many ways to do this:
We all have Google accounts, so let's use them for auth
Terminology
Resource Owner
User Agent
Client
(my-app.ovo.com)
Authorization Server
Resource Server
Authorization Code Grant flow
Resource Owner
Client
Authorization Server
Resource Server
GET /
(not logged in)
Authorization Code Grant flow
Resource Owner
Client
303 SEE_OTHER
https://accounts.google.com/o/oauth2/v2/auth?
response_type=code&
client_id=...&
scope=openid email profile&
state=asdfqwer&
redirect_uri=http://my-app.ovo.com/callback
Authorization Server
Resource Server
Authorization Code Grant flow
Resource Owner
Client
GET
https://accounts.google.com/o/oauth2/v2/auth?
response_type=code&
client_id=...&
scope=openid email profile&
state=asdfqwer&
redirect_uri=http://my-app.ovo.com/callback
Authorization Server
Resource Server
Authorization Code Grant flow
Resource Owner
Client
303 SEE_OTHER
http://my-app.ovo.com/callback?
code=xyxyxyxyxyx&
state=asdfqwer
Authorization Server
Resource Server
Authorization Code Grant flow
Resource Owner
Client
GET
http://my-app.ovo.com/callback?
code=xyxyxyxyxyx&
state=asdfqwer
Authorization Server
Resource Server
Authorization Code Grant flow
Resource Owner
Client
Check
state
Authorization Server
Resource Server
GET
http://my-app.ovo.com/callback?
code=xyxyxyxyxyx&
state=asdfqwer
Authorization Code Grant flow
Client
GET
https://www.googleapis.com/oauth2/v4/token?
code=xyxyxyxyxyx&
client_id=...&
client_secret=...&
grant_type=authorization_code&
redirect_uri=http://my-app.ovo.com/callback
Authorization Server
Resource Server
Authorization Code Grant flow
Client
access_token and id_token
(JWT containing user ID and email address)
Authorization Server
Resource Server
Authorization Code Grant flow
Client
GET
https://www.googleapis.com/oauth2/v3/userinfo
Authorization: Bearer <access token>
Authorization Server
Resource Server
Authorization Code Grant flow
Client
User profile including given name, family name, profile picture, gender, ...
Authorization Server
Resource Server
Resource Owner
Your app's API
Authorization Server
Resource Server
CDN
JS
Implicit Grant flow
Resource Owner
Your app's API
Authorization Server
Resource Server
CDN
GET /
(not logged in)
Implicit Grant flow
Resource Owner
Your app's API
Authorization Server
Resource Server
CDN
HTML and JS (includes client_id)
JS
Resource Owner
Your app's API
Authorization Server
Resource Server
CDN
JS
Implicit Grant flow
GET
https://accounts.google.com/o/oauth2/v2/auth?
response_type=token&
client_id=...&
scope=openid email profile&
state=asdfqwer&
redirect_uri=http://my-app.ovo.com/callback
Resource Owner
Your app's API
Authorization Server
Resource Server
CDN
JS
Implicit Grant flow
303 SEE_OTHER
https://my-app.ovo.com/callback#
state=asdfqwer&
access_token=yoloyolo&
token_type=Bearer&
expires_in=3600
Resource Owner
Your app's API
Authorization Server
Resource Server
CDN
JS
Implicit Grant flow
303 SEE_OTHER
https://my-app.ovo.com/callback#
state=asdfqwer&
access_token=yoloyolo&
token_type=Bearer&
expires_in=3600
Check
state
Resource Owner
Your app's API
Authorization Server
Resource Server
CDN
JS
Implicit Grant flow
GET
https://www.googleapis.com/oauth2/v3/tokeninfo?
access_token=asdfasdf
Resource Owner
Your app's API
Authorization Server
Resource Server
CDN
JS
Implicit Grant flow
JSON response including
client_id and user_id
Resource Owner
Your app's API
Authorization Server
Resource Server
CDN
JS
Implicit Grant flow
JSON response including
client_id and user_id
Check
client_id
Resource Owner
Your app's API
Authorization Server
Resource Server
CDN
JS
Implicit Grant flow
GET
/payments/history
Authorization: Bearer <access token>
Resource Owner
Your app's API
Authorization Server
Resource Server
CDN
JS
Implicit Grant flow
Validate access token
Resource Owner
Your app's API
Authorization Server
Resource Server
CDN
JS
Implicit Grant flow
JSON response including
client_id and user_id
Resource Owner
Your app's API
Authorization Server
Resource Server
CDN
JS
Implicit Grant flow
JSON response including
client_id and user_id
Check
client_id
Resource Owner
Your app's API
Authorization Server
Resource Server
CDN
JS
Implicit Grant flow
Respond with payments history
The official Getting Started guide is good