Skip to content

Instance Method

cachedOrNewToken()

Return the cached token if still valid (with a 60-second buffer), otherwise generate and cache a new one.

func cachedOrNewToken() async throws -> String

Return Value

A valid JWT token string.

Discussion

Concurrent callers that both observe a cache miss share a single in-flight Task so only one JWT signing operation is performed at a time.