Authorization Code Flow

1
2
3
Build the authorization URL and redirect the user to the authorization server
After the user is redirected back to the client, verify that the state matches
Exchange the authorization code for an access token
3. Exchange the code for token

Now that we have the authorization code, we can exchange it for an access token. This is done by sending a POST request to the token endpoint.

With body data:

Let's break it down...

  • The token endpoint URL

  • grant_type=

    The grant type, in this case authorization_code

  • client_id=

    Client ID of the application. This is a public identifier for the client, and it is used by the authorization server to identify the application when redirecting the user back to the client.

  • redirect_uri=

    The redirect URI

  • code=

    This is the authorization code we got in the previous step and is used to obtain the access token.