parse

suspend fun parse(token: String): JwtInstance(source)

Auto-detects the token type and delegates to parseSigned (3 parts) or parseEncrypted (5 parts).

Return

the parsed JwtInstance, either a JwtInstance.Jws or JwtInstance.Jwe

Parameters

token

the compact JWT serialization to parse

See also

Throws

if the token does not have 3 or 5 dot-separated parts

if the algorithm is unrecognised, or if alg=none and unsecured tokens are not allowed

if the signature does not verify or decryption fails

if the token is past its expiration

if the token is not yet valid

if a required claim is absent

if a required claim has an unexpected value