次の方法で共有


TokenCacheExtensions.AddDistributedTokenCache Method

Definition

Add a distributed token cache.

public static Microsoft.Identity.Client.IConfidentialClientApplication AddDistributedTokenCache (this Microsoft.Identity.Client.IConfidentialClientApplication confidentialClientApp, Action<Microsoft.Extensions.DependencyInjection.IServiceCollection> initializeDistributedCache);
static member AddDistributedTokenCache : Microsoft.Identity.Client.IConfidentialClientApplication * Action<Microsoft.Extensions.DependencyInjection.IServiceCollection> -> Microsoft.Identity.Client.IConfidentialClientApplication
<Extension()>
Public Function AddDistributedTokenCache (confidentialClientApp As IConfidentialClientApplication, initializeDistributedCache As Action(Of IServiceCollection)) As IConfidentialClientApplication

Parameters

confidentialClientApp
IConfidentialClientApplication

Confidential client application.

initializeDistributedCache
Action<IServiceCollection>

Action taking a IServiceCollection and by which you initialize your distributed cache.

Returns

The application for chaining.

Examples

The following code adds a token cache based on REDIS and initializes its configuration.

app.AddDistributedTokenCache(services =>
{
     // Redis token cache
     // Requires to reference Microsoft.Extensions.Caching.StackExchangeRedis
     services.AddStackExchangeRedisCache(options =>
     {
         options.Configuration = "localhost";
         options.InstanceName = "Redis";
     });
});

Remarks

Don't use this method in ASP.NET Core. Just add use the ConfigureServices method instead.

Applies to