requireRequestToken()function

requireRequestToken(request: Request, caller: AnyCaller = requireRequestToken): string
ParamType
requestRequest
The Request object containing an Authorization: Bearer {token} header to extract the token from. required
callerAnyCaller
Identity of the calling function for error attribution. Defaults to requireRequestToken
Return
string
The string token extracted from the Authorization header.
Throws
unknown
UnauthorizedError If the Authorization header is not set, or the JWT it contains is not well-formed.

Extract the Authorization: Bearer {token} from a Request object, or throw UnauthorizedError if not set or malformed.

Examples

requireRequestToken(request) // "eyJ..."