Skip to content

Instance Method

verify(_:as:iteratingKeys:)

Verifies and decodes a JWT token to extract the payload.
func verify<Payload>(_ token: String, as _: Payload.Type = Payload.self, iteratingKeys: Bool = false) async throws -> Payload where Payload : JWTPayload

Parameters

token

A JWT token string.

as

The type of payload to decode.

iteratingKeys

Whether to try verifying the token with all keys in the collection.

Return Value

The verified and decoded payload of the specified type.

Discussion

Throws

An error if the token cannot be verified or decoded.