I have secret, client id and user data. How to create valid keycloak token with full payload using jwt.io repo or any other in Java:
jti, exp, sub, aud, nbf, itp...
"allowed-origins": [ "http://localhost:8080", "http://localhost:4200" ], itp...
"realm_access": { "roles": [ "uma_authorization" ] }, itp...
I know this is old but maybe it helps someone. You can use the keycloak admin library to get a token from your keycloak.
Code:
Keycloak instance = Keycloak.getInstance(keycloakUrl, keycloakRealm, keycloakUsername, keycloakPassword, keycloakClientId, keycloakClientSecret);
TokenManager tokenmanager = instance.tokenManager();
String keycloakToken = tokenmanager.getAccessTokenString();
POM import:
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>20.0.2</version>
</dependency>
Alternatively you can request a token from the token endpoint from your keycloak.