Alokai

ensureAccessTokenValidity

Method that prepares JWTs for SCAPI, OCAPI, or both depending on the client configuration. If no tokens are passed in the request, new guest tokens are generated. If there are tokens included in the request, they get refreshed if needed.

This method runs for both OCAPI and SCAPI. It does not return anything, but sets JWT tokens and USID cookies. For OCAPI, it calls the Get or refresh customer JWT resource. For SCAPI, it goes through the Guest User Private Client SLAS Flow, generating or refreshing the token as needed.

Signature

export declare function ensureAccessTokenValidity(
	
): Promise<any>;

Examples

Ensuring that a valid token is available.

import { sdk } from '~/sdk.config.ts';

const category = await sdk.commerce.ensureAccessTokenValidity();

On this page