Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

[Bug] token cache file not getting created when referencing DLLs instead of nupkg #97

Closed
hiteshdasikamw opened this issue Aug 21, 2020 · 2 comments
Assignees
Labels
external question Further information is requested

Comments

@hiteshdasikamw
Copy link

            app = PublicClientApplicationBuilder.Create(clientId).WithTenantId(tenant).WithAuthority(authority).Build();
            StorageCreationPropertiesBuilder storageCreationPropertiesBuilder = new StorageCreationPropertiesBuilder("tokenCache.dat", "tokencache", clientId).
                WithLinuxKeyring("test", "default", "Get Access Token",
                new System.Collections.Generic.KeyValuePair<string, string>("Version", "1"),
                new System.Collections.Generic.KeyValuePair<string, string>("ProductGroup", "Test")).WithMacKeyChain("Test", "default");
            var task = Task.Run(async () => await MsalCacheHelper.CreateAsync(storageCreationPropertiesBuilder.Build()));
            MsalCacheHelper msalCacheHelper = task.Result;
            try
            {
                msalCacheHelper.RegisterCache(app.UserTokenCache);
                Task<AuthenticationResult> result = app.AcquireTokenByIntegratedWindowsAuth(scopes).WithUsername(username).ExecuteAsync();
                Console.Write(result.Result.AccessToken);
            }

I am using Microsoft.Identity.Client -> 4.15.0 and Microsoft.Identity.Client.Extensions -> 2.12.0. The issue is that tokencache folder gets created but tokenCache.dat doesnt get created. I am having the DLLs downloaded from the respective Nuget packages and adding them as a Reference in the .NET core console project.

This works absolutelyt fine and cache file gets created If I directly link the package from Nuget package manager. I am not really sure what is happening here. It might not be a bug, but want to see if anyone can help here?

@henrik-me henrik-me added bug Something isn't working P2 labels Oct 13, 2020
@bgavrilMS bgavrilMS added question Further information is requested external and removed bug Something isn't working P2 labels Oct 13, 2020
@bgavrilMS
Copy link
Member

Hi @hiteshdasikamw - so it looks like things are working well if you are using NuGet packages, but not so good if you are using DLLs. Obvious solution is to not use DLLs :) as can be difficult to reproduce what NuGet is trying to do.

MSAL has a pretty complex build output, as it creates both lib and ref assemblies. You should reference the lib assembly, as the ref assemblies have no code.

@bgavrilMS bgavrilMS changed the title [Bug] token cache file not getting created when using Integrated Windows Authentication [Bug] token cache file not getting created when using DLLs not NuGets Oct 13, 2020
@bgavrilMS bgavrilMS changed the title [Bug] token cache file not getting created when using DLLs not NuGets [Bug] token cache file not getting created when referencing DLLs instead of nupkg Oct 13, 2020
@bgavrilMS
Copy link
Member

Latest MSAL library no longer uses reference assemblies. It should be pretty simple to use DLLs if you understand multi-targetting.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
external question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants