Authorization Code Flow
1. Build the Authorization URL
?
&
&
&
&
&
Let's break it down...
-
URL of the authorization endpoint on the server. How is this path constructed will differ between OAuth providers (such as Keycloak or Okta). to find out the proper URL, there always exists /.well-known/openid-configuration endpoint that contains all the necessary information.
-
response_type=
OAuth 2.0 response type. In this case, we are using the Authorization Code flow, so we are requesting the 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=
Redirect URI of the client. This is the URL that the authorization server will redirect the user back to after the user has logged in and granted permissions. The redirect URI must match one of the URIs registered for the client ID.
-
scope=
Scopes requested by the client. Scopes are used to limit the access of the access token. In this case, we are requesting the offline_access scope, which allows the client to obtain a refresh token.
-
state=
State parameter. This is an optional parameter that the client can use to maintain state between the request and callback. The authorization server includes this parameter when redirecting the user back to the client, allowing the client to verify that the response is coming from the server and not a malicious third party.