Skip to content

Commit

Permalink
add cache configuration for accessToken
Browse files Browse the repository at this point in the history
  • Loading branch information
JhontSouth committed Nov 20, 2023
1 parent e4afa43 commit ee99567
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public MsalAppCredentials(IConfidentialClientApplication clientApplication, stri
_scope = scope;
_authority = authority;
_validateAuthority = validateAuthority;
if (_clientApplication != null)
{
_clientApplication.AppTokenCache.SetCacheOptions(CacheOptions.EnableSharedCacheOptions);
}
}

/// <summary>
Expand All @@ -78,6 +82,7 @@ public MsalAppCredentials(string appId, string appPassword, string authority = n
_clientApplication = ConfidentialClientApplicationBuilder.Create(appId)
.WithAuthority(authority ?? OAuthEndpoint, validateAuthority)
.WithClientSecret(appPassword)
.WithCacheOptions(CacheOptions.EnableSharedCacheOptions)
.Build();
}

Expand All @@ -102,6 +107,7 @@ public MsalAppCredentials(string appId, X509Certificate2 certificate, string aut
{
_clientApplication = ConfidentialClientApplicationBuilder.Create(appId)
.WithAuthority(authority ?? OAuthEndpoint, validateAuthority)
.WithCacheOptions(CacheOptions.EnableSharedCacheOptions)
.WithCertificate(certificate)
.Build();
}
Expand Down Expand Up @@ -130,6 +136,7 @@ public MsalAppCredentials(string appId, X509Certificate2 certificate, bool sendX
_clientApplication = ConfidentialClientApplicationBuilder.Create(appId)
.WithAuthority(authority ?? OAuthEndpoint, validateAuthority)
.WithCertificate(certificate, sendX5c)
.WithCacheOptions(CacheOptions.EnableSharedCacheOptions)
.Build();
}

Expand Down

0 comments on commit ee99567

Please sign in to comment.