2

I am using ADAL's (Microsoft.IdentityModel.Clients.ActiveDirectory v4.3.0) AuthenticationContext.AcquireTokenAsync to acquire a bearer token with a ClientCredential.

I am creating a new AuthenticationContext to acquire a token for each request. Is that thread-safe? Or do I have to lock the call to AcquireTokenAsync with a static SemaphoreSlim?

I am asking because according to http://www.cloudidentity.com/blog/2013/10/01/getting-acquainted-with-adals-token-cache/ the method uses a static token cache which is not thread-safe, but the article is quite old and I haven't found any more up-to-date information.

Mo B.
  • 5,307
  • 3
  • 25
  • 42

1 Answers1

4

ADAL.NET v4.3 can not at this point in time be considered thread safe. We are working towards this with MSAL v2+.

  • 2
    Another [relevant conversation here](https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/issues/1330) – RayLuo Nov 05 '18 at 22:38