question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AddDistributedTokenCaches without enabling MicrosoftIdentityWebAppAuthentication

See original GitHub issue

How to make use of the distributed sqlserver cache without enabling MicrosoftIdentityWebAppAuthentication?

I have a ConfidentialClientApplication which I created using this:

public MsalAuthProvider(IMsalTokenCacheProvider tokenCacheProvider)
{
    _app = ConfidentialClientApplicationBuilder.Create("<clientid>")
            .WithClientSecret("<clientsecret>")
            .WithAuthority("<authority>")
            .WithRedirectUri("<redirecturi>")
            .Build();

    tokenCacheProvider.InitializeAsync(_app.AppTokenCache);
    tokenCacheProvider.InitializeAsync(_app.UserTokenCache);
}

In the startup you can register the IMsalTokenCacheProvider using:

services.AddMicrosoftIdentityWebAppAuthentication()
    .EnableTokenAcquisitionToCallDownstreamApi()
    .AddDistributedTokenCaches();

services.AddDistributedSqlServerCache(options => { //options... });

I want to use the sql server cache but I do not want to enable authentication towards azuread because it conflicts with my own authentication towards my own IdentityServer

services.AddAuthentication("Bearer")
    .AddJwtBearer("Bearer", options => { //options...});

Can I register / inject the IMsalTokenCacheProvider some other way so I can prevent the usage of AddMicrosoftIdentityWebAppAuthentication?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

1reaction
jennyf19commented, Nov 20, 2020

cool. we can release it after the MSAL .NET release then.

1reaction
jmprieurcommented, Nov 20, 2020

@jennyf19, @henrik-me, as discussed let’s take it in 1.3.1 (which therefore become 1.4.0) I also benefits to MSAL.NET users wanting to use net472

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Feature Request] Allow AddDistributedTokenCaches to ...
Ideally, we want to only use distributed token cache for the OIDC flow (AcquireTokenByAuthorizationCode) because it is required. A machine in- ...
Read more >
Token cache serialization (MSAL.NET) - Microsoft Entra
AddDistributedTokenCaches, The token cache is an adapter against the ASP.NET Core IDistributedCache implementation. It enables you to choose ...
Read more >
TokenCacheExtensions.AddDistributedTokenCache Method
Action taking a IServiceCollection and by which you initialize your distributed cache. Returns. IConfidentialClientApplication. The application for chaining.
Read more >
Untitled
... option must be provided Enable web app authentication options using Azure … ... social.msdn.microsoft.com AddDistributedTokenCaches without enabling .
Read more >
Using MSAL to get access token and cache it in SQL DB ...
I want to authenticate AAD users to access powerBi resources through MSAL by using application ID and secret. So i want to get...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found