azure-databricks-client icon indicating copy to clipboard operation
azure-databricks-client copied to clipboard

Auto/background refresh for WorkloadIdentity/TokenCredential

Open dineshtsm opened this issue 1 year ago • 1 comments

memoryz Thanks for resolving the issue with #191. Can you please implement auto/background refresh for WorkloadIdentity/TokenCredential, so that clients need not worry to refresh the token on expiry.

Pls refer line number 323 in the file : https://github.com/Azure/azure-cosmos-dotnet-v3/blob/dee9abaedf66b5663fdf33ea1f943cd9303e152a/Microsoft.Azure.Cosmos/src/CosmosClient.cs#L29

dineshtsm avatar Jun 24 '24 16:06 dineshtsm

Hi @dineshtsm I'm a little confused by your ask. The implementation doesn't cache anything - it passed in a function to the HttpMessageHandler (BearerHeaderHandler.cs) used by the HttpClient:

var httpClient = CreateHttpClient(
    baseUrl,
    async () => (await credential.GetTokenAsync(new TokenRequestContext(new string[] { DatabricksScope }), default)).Token,
    timeoutSeconds,
    httpClientConfig
);

This means every time a request is issued, a new access token is requested on the spot. The clients don't need to refresh token since the clients don't even have access to the requested token.

memoryz avatar Sep 05 '24 07:09 memoryz