AcquireTokenAsync是线程安全的吗? [英] Is AcquireTokenAsync thread-safe?

查看:155
本文介绍了AcquireTokenAsync是线程安全的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆