PKCE Flow

1
2
3
4
Create a secret code verifier and code challenge
Build the authorization URL and redirect the user to the authorization server
After the user is redirected back to the client, verify the state
Exchange the authorization code and code verifier for an access token
4. Exchange the code and code verifier 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.

  • code_verifier=

    This is the code verifier we generated in the first step. It is used to verify the identity of the client.