getSignedJwt method
Create and sign a JWT for the given issuer. The JWT is signed with RSA256 algorithm and the given private key.
Implementation
String getSignedJwt(String issuer) {
final claims = JsonWebTokenClaims.fromJson({
"iss": userId,
"sub": userId,
"iat": DateTime.now().toUtc().millisecondsSinceEpoch ~/ 1000,
"exp": DateTime.now()
.toUtc()
.add(Duration(minutes: 1))
.millisecondsSinceEpoch ~/
1000,
"aud": issuer,
});
final builder = JsonWebSignatureBuilder();
builder.jsonContent = claims.toJson();
builder.addRecipient(JsonWebKey.fromPem(key, keyId: keyId),
algorithm: 'RS256');
final signature = builder.build();
return signature.toCompactSerialization();
}