0
我目前正在檢索令牌並運行所有我想運行的代碼,但我無法弄清楚如何「刷新」我的令牌。一小時後過期。這種檢索App-Only令牌的方法不會返回刷新令牌。辦公室365應用程序唯一令牌刷新/更新
如何「刷新/更新」令牌?
我用下面的方法來檢索令牌:
string authority = appConfig.AuthorizationUri.Replace("common", tenantId);
AuthenticationContext authenticationContext = new AuthenticationContext(authority,false);
string certfile = Server.MapPath(appConfig.ClientCertificatePfx);
X509Certificate2 cert = new X509Certificate(certfile,appConfig.ClientCertificatePfxPassword, X509KeyStorageFlags.MachineKeySet);
ClientAssertionCertificate cac = new ClientAssertionCertificate(appConfig.ClientId, cert);
var authenticationResult = await authenticationContext.AcquireTokenAsync(resource, cac);
return authenticationResult.AccessToken;