OAuth
Terminology
In this example user hase images on Google Drive and wants to print them at some external Printing Service
Protected Resource - images on Google Drive
Resource Owner - user who owns images, he has access to
Protected Resource and he can grant access rights
Resource Server - service where Protected Resource is stored. In this example it is Google Drive
Client - application that needs to access Protected Resource on behalf of the Resource owner
and with its authorization. In this example it is Printing Service
Authorization Server - service responsible for authorized acces to Protected Resource.
It is issuing Access Tokens to the Client
Workflow
Authorization Code Flow
Brief Description
| Source | Destination | Message / Action | ||
|---|---|---|---|---|
| Resource Owner | → | Client | Do something with my Protected Resource | |
| Client | → | Authorization Server | Need access to Protected Resource | |
| Authorization Server | → | Resource Owner | Should I give access to your Protected Resource? | |
| Resource Owner | → | Authorization Server | Yes | |
| Authorization Server | → | Client | Authorization Token | |
| Client | → | Authorization Server |
Authorization Token
+ Give me Access Token | |
| Authorization Server | → | Client | Access Token | |
| Client | → | Resource Server | Access Token + Give me access to Protected Resource | |
| Resource Server | → | Client | Access to Protected Resource |
1 The User (Resource Owner) addresses the Client with a request to print their photos (Protected Resource) Google Drive (Resource Server)
(2) The Printing Service (Client) communicates to the Authorization Server that it needs to print photos. The user (Resource Owner) transmits data about the user and about the photos to which he needs access.
(3) Authorization Server accesses Resource Owner and informs that Client has requested access to Protected Resourse and He wants to do certain things. Question: Do you agree with Resource Owner?
4) Resource Owner says it's OK
5) Authorizaion Server sends to the client (Client) Authorization Token . This is usually a short-lived token.
6) Client requests from Autorization Server Access Token . To this request It adds the previously received Authorization Token .
(7) Authorizaion Server checks Authorization Token and sends it to the Client. Access Token
8) Client and sends to Resource Server Access Token and request access to Protected Resources
9) Resource Server check out Access Token and gives Client access to Protected Resources
Article author: Andrei Olegovich