Handling the Callback
After the user authenticates, they are redirected back to your application with an authorization code.
Steps:
Retrieve Authorization Code and State: Extract these from the query parameters.
Verify State: Ensure the state matches the one you generated earlier.
Exchange Authorization Code for Tokens: Send a POST request to the token endpoint to exchange the authorization code for ID, access, and refresh tokens.
Example Callback Handling:
Token Request Parameters
grant_type
The type of grant being requested. For authorization code flow, use authorization_code
.
code
The authorization code received from the authorization endpoint.
redirect_uri
The URI to which the response will be sent. It must match the redirect URI registered with the client.
client_id
The client ID you obtained during client registration.
code_verifier
The PKCE code verifier.
Example Token Request Body
Token Response Fields
access_token
The token that can be used to access protected resources.
id_token
A JWT that contains user identity information.
refresh_token
A token that can be used to obtain new access tokens.
token_type
The type of token issued. Typically Bearer
.
expires_in
The duration in seconds for which the access token is valid.
Example Token Response
Last updated