buildJwt
suspend fun buildJwt(type: String, key: AsymmetricKey, header: suspend JsonObjectBuilder.() -> Unit = {}, creationTime: Instant = Clock.System.now(), expiresIn: Duration? = null, body: suspend JsonObjectBuilder.() -> Unit): String
Creates a JWT message signed with the given key.
JWT header contains type (typ), signature algorithm (alg) and, unless the key is AsymmetricKey.Anonymous, key identification (either kid or x5c). The body of the JWT will have issuance time (iat) and optionally expiration time (exp), unless creationTime is set to Instant.DISTANT_PAST
Return
signed JWT
Parameters
type
JWT type
key
private key to sign JWT and provide key identifying information in the JWT header
header
JSON object builder block to provide additional header fields
creationTime
JWT issuance timestamp (iat)
expiresIn
validity duration for the JWT (if any)
body
JSON object builder block for JWT body