'Is it possible to generate JWT token with certain role in keycloak?

I am wondering that is it possible to generate JWT token with certain role in keycloak. After user login successfully, user select one of his/her roles then I regenerate jwt token with only specified role. It is important because I have microservices and authorization in this services require role policy which role comes from jwt.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source