Obtaining an access token
The most common way to obtain an access token that can be used to, for example, invoke a secure REST API is through the OAuth 2.0 Authorization Code grant type.
In summary, to obtain an access token, an application redirects to Keycloak, which authenticates the user and optionally prompts the user to grant the application access or not, before returning an access token to the application. The application can then include the access token in the requests it sends to the REST API, allowing the REST API to verify whether access should be provided.
In the following diagram, the authorization code grant type is shown in more detail:
The steps in the diagram in more detail are as follows:
- The user performs an action that requires sending a request to an external REST API.
- The application generates an authorization request.
- The authorization request is sent to the...