Skip to content

Authorization

SDK Reference · Resource

Authorization

Sign in, create accounts, recover access, and refresh access tokens.

method

login()

Sign in with email or username

Checks account credentials and returns an access token plus a refresh token. Send the access token as `Authorization: Bearer `.

Signature

Promiseclient.authorization.login(options: AuthorizationLoginOptions): Promise<AuthorizationLoginResponse>

Parameters

NameTypeRequirementDescription
acceptLanguagestringOptionalPreferred language for human-readable API errors. Supported languages: en, ru, uk, de, it, fr, es, zh-hans, ja. Regional language tags and quality weights are accepted; unsupported or omitted values use English.
bodyLoginRequestRequestRequired—

Example

const result = await client.authorization.login({
body: {
"password": "Correct-Horse-Battery-Staple-42"
}
});

Returns

TokenPairResponse

The operation completed successfully.

typeTokenPairResponse2fields
token
string
Required
Short-lived access token used in the Authorization header.
refresh
string
Required
Long-lived token used to request a new access token.

Throws

ApiError

Normalized API, transport, and response processing failure.

  • kind: "validation"The request arguments or business rules are invalid.
  • kind: "network"The request could not reach ProxyRequest.
  • kind: "unexpected"The response could not be decoded or did not match the SDK contract.
Advanced variants
  • client.authorization.loginWithResponse(options): Promise<ApiResponse<AuthorizationLoginResponse>>

    Returns response status, headers, ETag and idempotency metadata with the decoded data.

method

loginWithGoogle()

Sign in with Google

Verifies a Google ID token, creates or links the matching customer account when needed, and returns an API token pair.

Signature

Promiseclient.authorization.loginWithGoogle(options: AuthorizationLoginWithGoogleOptions): Promise<AuthorizationLoginWithGoogleResponse>

Parameters

NameTypeRequirementDescription
acceptLanguagestringOptionalPreferred language for human-readable API errors. Supported languages: en, ru, uk, de, it, fr, es, zh-hans, ja. Regional language tags and quality weights are accepted; unsupported or omitted values use English.
bodyGoogleAuthRequestRequired—

Example

const result = await client.authorization.loginWithGoogle({
body: {
"credential": "{credential}"
}
});

Returns

TokenPairResponse

The operation completed successfully.

typeTokenPairResponse2fields
token
string
Required
Short-lived access token used in the Authorization header.
refresh
string
Required
Long-lived token used to request a new access token.

Throws

ApiError

Normalized API, transport, and response processing failure.

  • kind: "validation"The request arguments or business rules are invalid.
  • kind: "permission"The authenticated account cannot perform this operation.
  • kind: "network"The request could not reach ProxyRequest.
  • kind: "unexpected"The response could not be decoded or did not match the SDK contract.
Advanced variants
  • client.authorization.loginWithGoogleWithResponse(options): Promise<ApiResponse<AuthorizationLoginWithGoogleResponse>>

    Returns response status, headers, ETag and idempotency metadata with the decoded data.

method

verifyOtp()

Complete two-factor sign-in

Exchanges a single-use sign-in challenge and authenticator code for account tokens.

Signature

Promiseclient.authorization.verifyOtp(options: AuthorizationVerifyOtpOptions): Promise<AuthorizationVerifyOtpResponse>

Parameters

NameTypeRequirementDescription
acceptLanguagestringOptionalPreferred language for human-readable API errors. Supported languages: en, ru, uk, de, it, fr, es, zh-hans, ja. Regional language tags and quality weights are accepted; unsupported or omitted values use English.
bodyVerifyOTPRequestRequired—

Example

const result = await client.authorization.verifyOtp({
body: {
"challenge": "{challenge}",
"code": "{code}"
}
});

Returns

TokenPairResponse

The operation completed successfully.

typeTokenPairResponse2fields
token
string
Required
Short-lived access token used in the Authorization header.
refresh
string
Required
Long-lived token used to request a new access token.

Throws

ApiError

Normalized API, transport, and response processing failure.

  • kind: "validation"The request arguments or business rules are invalid.
  • kind: "network"The request could not reach ProxyRequest.
  • kind: "unexpected"The response could not be decoded or did not match the SDK contract.
Advanced variants
  • client.authorization.verifyOtpWithResponse(options): Promise<ApiResponse<AuthorizationVerifyOtpResponse>>

    Returns response status, headers, ETag and idempotency metadata with the decoded data.

method

recoverPassword()

Send a password recovery email

Validates the anti-bot token and sends account recovery instructions to the supplied email address.

Signature

Promiseclient.authorization.recoverPassword(options: AuthorizationRecoverPasswordOptions): Promise<AuthorizationRecoverPasswordResponse>

Parameters

NameTypeRequirementDescription
acceptLanguagestringOptionalPreferred language for human-readable API errors. Supported languages: en, ru, uk, de, it, fr, es, zh-hans, ja. Regional language tags and quality weights are accepted; unsupported or omitted values use English.
bodyRecoverPasswordRequestRequired—

Example

const result = await client.authorization.recoverPassword({
body: {
"email": "[email protected]",
"token": "{token}"
}
});

Returns

PasswordRecoveryResponse

The operation completed successfully.

typePasswordRecoveryResponse2fields
message
string
Required
—
email
string
Required
—

Throws

ApiError

Normalized API, transport, and response processing failure.

  • kind: "validation"The request arguments or business rules are invalid.
  • kind: "network"The request could not reach ProxyRequest.
  • kind: "unexpected"The response could not be decoded or did not match the SDK contract.
Advanced variants
  • client.authorization.recoverPasswordWithResponse(options): Promise<ApiResponse<AuthorizationRecoverPasswordResponse>>

    Returns response status, headers, ETag and idempotency metadata with the decoded data.

method

refresh()

Refresh an access token

Uses a valid refresh token to issue a new short-lived access token for the same account session.

Signature

Promiseclient.authorization.refresh(options: AuthorizationRefreshOptions): Promise<AuthorizationRefreshResponse>

Parameters

NameTypeRequirementDescription
acceptLanguagestringOptionalPreferred language for human-readable API errors. Supported languages: en, ru, uk, de, it, fr, es, zh-hans, ja. Regional language tags and quality weights are accepted; unsupported or omitted values use English.
bodyTokenRefreshRequestRequestRequired—

Example

const result = await client.authorization.refresh({
body: {
"refresh": "{refresh}"
}
});

Returns

TokenRefreshResponse

The operation completed successfully.

typeTokenRefreshResponse1field
access
string
Required
New access token for the same account session.

Throws

ApiError

Normalized API, transport, and response processing failure.

  • kind: "validation"The request arguments or business rules are invalid.
  • kind: "authentication"Authentication credentials are missing, expired, or invalid.
  • kind: "network"The request could not reach ProxyRequest.
  • kind: "unexpected"The response could not be decoded or did not match the SDK contract.
Advanced variants
  • client.authorization.refreshWithResponse(options): Promise<ApiResponse<AuthorizationRefreshResponse>>

    Returns response status, headers, ETag and idempotency metadata with the decoded data.

method

signup()

Create a customer account

Creates an account after validating the email, password, and Cloudflare Turnstile token. Referral and affiliate codes are optional.

Signature

Promiseclient.authorization.signup(options: AuthorizationSignupOptions): Promise<AuthorizationSignupResponse>

Parameters

NameTypeRequirementDescription
acceptLanguagestringOptionalPreferred language for human-readable API errors. Supported languages: en, ru, uk, de, it, fr, es, zh-hans, ja. Regional language tags and quality weights are accepted; unsupported or omitted values use English.
bodySignUpRequestRequired—

Example

const result = await client.authorization.signup({
body: {
"email": "[email protected]",
"password": "Correct-Horse-Battery-Staple-42",
"token": "{token}"
}
});

Returns

TokenPairResponse

The resource or action result was created successfully.

typeTokenPairResponse2fields
token
string
Required
Short-lived access token used in the Authorization header.
refresh
string
Required
Long-lived token used to request a new access token.

Throws

ApiError

Normalized API, transport, and response processing failure.

  • kind: "validation"The request arguments or business rules are invalid.
  • kind: "permission"The authenticated account cannot perform this operation.
  • kind: "network"The request could not reach ProxyRequest.
  • kind: "unexpected"The response could not be decoded or did not match the SDK contract.
Advanced variants
  • client.authorization.signupWithResponse(options): Promise<ApiResponse<AuthorizationSignupResponse>>

    Returns response status, headers, ETag and idempotency metadata with the decoded data.