本文介绍了Azure AD客户端凭据刷新访问令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发守护程序(仅适用于应用程序或无人参与)服务,以使用EWS与Office 365通信,为此,我已经使用以下代码成功获取了令牌.

X509Certificate2 cert =新的X509Certificate2(pfxCertificateFilePath,pfxPassword,X509KeyStorageFlags.MachineKeySet);
ClientAssertionCertificate cac =新的ClientAssertionCertificate(clientId,cert);
AuthenticationContext authenticationContext = new
AuthenticationContext(authApiUri);
AuthenticationResult authenticationResult =等待authenticationContext.AcquireTokenAsync(resourceServerName,cac);
authenticationResult.AccessToken;

I am developing a Daemon (App-Only or Unattended) service to communicate with office 365 using EWS, to do this I have acquired a token successfully using following code.

X509Certificate2 cert = new X509Certificate2(pfxCertificateFilePath, pfxPassword, X509KeyStorageFlags.MachineKeySet);
ClientAssertionCertificate cac = new ClientAssertionCertificate(clientId, cert);
AuthenticationContext authenticationContext = new 
AuthenticationContext(authApiUri);
AuthenticationResult authenticationResult = await authenticationContext.AcquireTokenAsync(resourceServerName, cac);
authenticationResult.AccessToken;

我正在寻找一个选项,以刷新使用ClientAssertionCertificate获取的访问令牌.是否可以刷新使用ClientAssertionCertificate获取的访问令牌?

I am looking for an option to refresh the access token which is acquired using ClientAssertionCertificate. 
Is it possible to refresh the access token which is acquired using ClientAssertionCertificate?

谢谢

Mahendran

Mahendran

推荐答案

否,您要描述的内容是不可能的. ClientAssertionCertificate不返回刷新令牌.

No, what you are describing is not possible. The ClientAssertionCertificate does not return a refresh token. 

但是,您可以在访问令牌和客户端断言令牌上设置到期时间.

You can, however, set an expiration time on the access token and client assertion token. 

https://msdn.microsoft.com/zh-CN/library/mt473615.aspx?f=255&MSPPError=-2147217396

https://msdn.microsoft.com/en-us/library/mt473615.aspx?f=255&MSPPError=-2147217396



这篇关于Azure AD客户端凭据刷新访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 07:01