PKCE Flow
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:
-
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.