I am unable to use ConfidentialClientApplicationBuilder with userTokenCache.
Code in samples look something like this but this code is obsolete now and I am supposed to use ConfidentialClientApplicationBuilder.
ConfidentialClientApplication app;
var request = httpContext.Request;
var currentUri = UriHelper.BuildAbsolute(request.Scheme, request.Host, request.PathBase, _azureAdOptions.CallbackPath ?? string.Empty);
var credential = new ClientCredential(_azureAdOptions.ClientSecret);
TokenCache userTokenCache = _tokenCacheProvider.GetCache(httpContext, claimsPrincipal, authenticationProperties, signInScheme);
string authority = $"{_azureAdOptions.Instance}{_azureAdOptions.TenantId}/";
app = new ConfidentialClientApplication(_azureAdOptions.ClientId, authority, currentUri, credential, userTokenCache, null);
return app;
ConfidentialClientApplicationBuilder Code
IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(_azureAdOptions.ClientId)
.WithAuthority(authority)
.WithRedirectUri(currentUri)
.WithCertificate(clientCertificate)
.Build();
Its done a bit differently now.
You initialize the TokenCache implementation separately and attach it to the app object. see this line for reference.
Its highly recommended you study how the Token Cache is best implemented for MSAL. The TokenCacheProviders folder has the implementations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With