Skip to content

node-zendesk / Exports / clients/authorization-handler / AuthorizationHandler

Class: AuthorizationHandler

clients/authorization-handler.AuthorizationHandler

Handles the creation of authorization headers based on the provided configuration. Supports both OAuth and Basic Authentication methods.

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new AuthorizationHandler(options): AuthorizationHandler

Creates a new instance of the AuthorizationHandler.

Parameters

NameTypeDescription
optionsMap<any, any>A Map object containing the necessary configuration options.

Returns

AuthorizationHandler

Defined in

clients/authorization-handler.d.ts:10

Properties

options

options: Map<any, any>

Defined in

clients/authorization-handler.d.ts:11

Methods

createAuthorizationHeader

createAuthorizationHeader(): string

Determines the authentication method and creates the appropriate authorization header.

Returns

string

The resulting authorization header string.

Defined in

clients/authorization-handler.d.ts:16


createBasicAuthHeader

createBasicAuthHeader(): string

Creates the Basic Authentication authorization header.

Returns

string

The Basic Authentication header.

Throws

When username or password/token is missing in the options.

Defined in

clients/authorization-handler.d.ts:33


createOAuthHeader

createOAuthHeader(): string

Creates the OAuth authorization header.

Returns

string

The OAuth authorization header.

Throws

When the token is missing in the options.

Defined in

clients/authorization-handler.d.ts:27


encodeCredentials

encodeCredentials(credentials): string

Encodes the provided credentials using base64 encoding.

Parameters

NameTypeDescription
credentialsstringThe credentials to be encoded.

Returns

string

The base64 encoded string of the provided credentials.

Defined in

clients/authorization-handler.d.ts:45


getPasswordOrToken

getPasswordOrToken(): string

Retrieves the password or token for Basic Authentication. The method first checks for a password and if none is found, it fetches the token.

Returns

string

The password or token prefixed with the appropriate separator.

Defined in

clients/authorization-handler.d.ts:39


isOAuth

isOAuth(): boolean

Checks if OAuth should be used for authentication.

Returns

boolean

True if OAuth is the chosen method; false otherwise.

Defined in

clients/authorization-handler.d.ts:21

Released under the MIT License.