AcquireTokenAsync是线程安全的吗? [英] Is AcquireTokenAsync thread-safe?
问题描述
我正在使用ADAL的(Microsoft.IdentityModel.Clients.ActiveDirectory v4.3.0)AuthenticationContext.AcquireTokenAsync
来获取带有ClientCredential
的承载令牌.
I am using ADAL's (Microsoft.IdentityModel.Clients.ActiveDirectory v4.3.0) AuthenticationContext.AcquireTokenAsync
to acquire a bearer token with a ClientCredential
.
我正在创建一个新的AuthenticationContext
来为每个请求获取一个令牌.那是线程安全的吗?还是我必须使用静态SemaphoreSlim
锁定对AcquireTokenAsync
的呼叫?
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.
推荐答案
在此时无法将ADAL.NET v4.3视为线程安全的.我们正在使用MSAL v2 +来实现这一目标.
ADAL.NET v4.3 can not at this point in time be considered thread safe. We are working towards this with MSAL v2+.
这篇关于AcquireTokenAsync是线程安全的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!