I am trying to verify the AccessToken using below code -
TokenVerifier verifier = TokenVerifier.create(StringAccessToken, AccessToken.class).withDefaultChecks(); PublicKey publicKey = getRealmPublicKey(verifier.getHeader()); return verifier.realmUrl(“someStringUrl”).publicKey(publicKey).verify().getToken();
But seems a realmUrl() method is deprecated. Can you please help with alternative solution for this?
or can you suggest an effective way to verify access token ?
We can use org.keycloak.TokenVerifier#withChecks which takes predicates for token validation. The realm check is performed by
org.keycloak.TokenVerifier.RealmUrlCheck
The modified code would be: