In some versions of keycloak, the use of lightweight token is enabled by default. This causes the loss of information such as the resource_access in the token. To enable it, go to the client -> Advanced tab -> Advanced settings -> Always use lightweight access token.