Skip to main content

getAuthorizationToken

@quik/http


@quik/http / getAuthorizationToken

Function: getAuthorizationToken()

getAuthorizationToken(headers): IQAuthorizationInformation

Defined in: http/src/utils/getAuthorizationToken.ts:27

Parses an Authorization header and returns its structured representation.

This function extracts the authentication scheme and token from the Authorization header. It supports standard formats like "Bearer token" or "Basic credentials" and returns a structured object with the scheme and token separated.

Parameters​

headers​

Record<string, any>

Request headers map containing the authorization header

Returns​

IQAuthorizationInformation

Example​

// With a valid Authorization header
const headers = { authorization: "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." };
const auth = getAuthorizationToken(headers);
// Returns: { scheme: "Bearer", token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." }

// With an invalid or missing Authorization header
const emptyHeaders = { };
const result = getAuthorizationToken(emptyHeaders);
// Returns: undefined

See​

IQAuthorizationInformation For the structure of the returned object