Provides low-level interfaces and helper methods for authentication in Azure SDK
Overall
score
97%
Build a token cache manager that intelligently handles access token storage and retrieval based on expiration tracking.
Implement a TokenCacheManager class that manages cached access tokens from credentials. The manager should:
The manager should accept a credential that has a getToken(scopes, options) method which returns access tokens with expiration timestamps.
When getToken() is called on the manager:
expiresOnTimestamp, return the cached tokenrefreshAfterTimestamp and the current time is after it, fetch a fresh tokenexpiresOnTimestamp), fetch a fresh tokenAll timestamps are in Unix epoch milliseconds (number of milliseconds since January 1, 1970 UTC). Use Date.now() to get the current time.
@generates
export interface AccessToken {
token: string;
expiresOnTimestamp: number;
refreshAfterTimestamp?: number;
}
export interface TokenCredential {
getToken(scopes: string | string[], options?: any): Promise<AccessToken | null>;
}
export class TokenCacheManager {
constructor(credential: TokenCredential);
getToken(scopes: string | string[]): Promise<AccessToken | null>;
}Provides authentication types and interfaces.
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