requireRequestToken()function
requireRequestToken(request: Request, caller: AnyCaller = requireRequestToken): string
| Param | Type | |
|---|---|---|
request | Request | The Request object containing an Authorization: Bearer {token} header to extract the token from. required |
caller | AnyCaller | 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..."