Skip to content
Advertisement

Refresh access_token via refresh_token in Keycloak

I need to make the user keep login in the system if the user’s access_token get expired and user want to keep login. How can I get newly updated access_token with the use of refresh_token on Keycloak?

I am using vertx-auth for the auth implementation with Keycloak on vert.x. Is it possible to refresh access_token with vertx-auth or Keycloak‘s REST API itself? Or what will be another implementation of this?

Advertisement

Answer

keycloak has REST API for creating an access_token using refresh_token. It is a POST endpoint with application/x-www-form-urlencoded

Here is how it looks:

JavaScript

This will give you new access token using refresh token.

NOTE: if your refresh token is expired it will throw 400 exception in that you can make user login again.

Check out a sample in Postman, you can develop and corresponding API using this.

Sample in Postman

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement