Gets or initializes the access token from memory or storage
Retrieves the current access token using a memory-first strategy:
This dual approach balances performance with reliability, ensuring token availability across application restarts.
The current access token or null if not available
// Get access token for API requestconst token = getAccessTokenState();if (token) { headers.Authorization = `Bearer ${token}`;} Copy
// Get access token for API requestconst token = getAccessTokenState();if (token) { headers.Authorization = `Bearer ${token}`;}
export function getAccessTokenState(): string | null { if (currentAccessToken) { return currentAccessToken; } // Try to load from persistent storage return retrieveTokenValue<string>(ACCESS_TOKEN_KEY);} Copy
export function getAccessTokenState(): string | null { if (currentAccessToken) { return currentAccessToken; } // Try to load from persistent storage return retrieveTokenValue<string>(ACCESS_TOKEN_KEY);}
Gets or initializes the access token from memory or storage
Retrieves the current access token using a memory-first strategy:
This dual approach balances performance with reliability, ensuring token availability across application restarts.