callWithAuth

suspend fun <T> callWithAuth(locale: String? = null, call: suspend (authMetadata: Metadata) -> T): T

Runs call with authorization: Bearer <token>, x-language and x-device-types metadata. locale is the language of the user's input (see localeHeaderValue); the device locale when null.

On UNAUTHENTICATED a fresh token is requested and the call is retried once. Other errors, and a failed retry, propagate to the caller.

Parameters

call

RPC invocation that receives auth metadata to attach to the outgoing request

Throws

if no valid token is available