Bhavesh Thummar
Bhavesh Thummar

Reputation: 1

How to validate my token from AddInMemoryTokenCaches in second request

I have implemented code to store Azure AD tokens in an InMemoryCache for validation. As a result, when accessing any [Authorized] endpoint, the validation process should occur using the tokens stored in the InMemoryCache, bypassing the need for additional Azure AD API calls.

builder.Services.AddAuthentication()
            .AddMicrosoftIdentityWebApi(configuration.GetSection("AzureAd"))
            .EnableTokenAcquisitionToCallDownstreamApi()
            .AddInMemoryTokenCaches(options =>
            {
                options.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(Convert.ToDouble(configuration["AzureAuthCacheInMinute"]));
            });

Upvotes: 0

Views: 83

Answers (0)

Related Questions