Provides low-level interfaces and helper methods for authentication in Azure SDK
Overall
score
97%
A token management service that provides caching and automatic refresh capabilities for authentication tokens used with Azure services.
You need to implement a token cache service that manages authentication tokens efficiently. The service should store tokens in memory, handle automatic refresh based on expiration times, and support multiple scope configurations.
The service must maintain an in-memory cache of authentication tokens, keyed by scope. When multiple scopes are requested together, they should be cached under a normalized key (e.g., sorted and joined scope strings).
When a token is requested:
Tokens should be considered expired when the current time exceeds their expiration timestamp. The service should proactively refresh tokens when the current time exceeds their refresh-after timestamp (if provided).
@generates
import { TokenCredential, AccessToken } from "@azure/core-auth";
/**
* TokenCacheService manages token caching and automatic refresh.
*/
export class TokenCacheService {
/**
* Creates a new TokenCacheService.
* @param credential - The credential to use for obtaining tokens
*/
constructor(credential: TokenCredential);
/**
* Gets a token for the specified scope(s), using cache when available.
* @param scopes - A single scope string or array of scope strings
* @returns A promise that resolves to an access token or null
*/
getToken(scopes: string | string[]): Promise<AccessToken | null>;
/**
* Clears all cached tokens.
*/
clearCache(): void;
/**
* Clears cached token for specific scope(s).
* @param scopes - A single scope string or array of scope strings
*/
clearCacheForScope(scopes: string | string[]): void;
}Provides token authentication interfaces and types for Azure services.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-azure--core-authdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10