Hi,
It looks like you're creating the token with the wrong format:
Instant now = Instant.now();
JsonObject decoded = new JsonObject()
.put("alg", "ES256")
.put("kid", "${AUTH_KEY_ID}")
.put("iss", "${TEAM_ID}")
.put("iat", now.getEpochSecond());
token = authProvider.generateToken(
decoded,
new JWTOptions()
.setAlgorithm("ES256"));
// {
// "typ": "JWT",
// "alg": "ES256"
// }.{
// "alg": "ES256",
// "kid": "${AUTH_KEY_ID}",
// "iss": "${TEAM_ID}",
// "iat": 1627582196
// }.[Signature]
While from that manual I think you want:
JsonObject payload = new JsonObject();
String token = authProvider.generateToken(
payload,
new JWTOptions()
.setIssuer("${TEAM_ID}")
.setAlgorithm("ES256")
.setHeader(new JsonObject().put("kid", "${AUTH_KEY_ID}")));
// {
// "kid": "${AUTH_KEY_ID}",
// "typ": "JWT",
// "alg": "ES256"
// }.{
// "iat": 1627580331,
// "iss": "${TEAM_ID}"
// }.[Signature]
Note that in order to change the default values or the contents of the header, you need to specify the fields in the jwtOptions, not on the claims.
"kid" is a missing property we should add a shortcut instead of needing the header to be provided manually (but that is an API improvement).
Let me know if this works for you!
Cheers,
Paulo