0
votes

I am developing Daemon (App-Only or Unattended) service to communicate with office 365 using EWS, to do this I have acquired a toke 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;

I am looking for an option to refresh the access token. I got chance to look at the wiki given by #adal team unfortunately I am confused with the following statement

Note that, AcquireTokenSilent does not need to be called in the Client credentials flow (when the application acquires token without a user, but in its own name)"

Please clarify how to refresh the token obtained by ClientAssertionCertificate.

Thanks Mahendran

1
I think it means that you refresh via application credentials instead. Have you checked this link? social.msdn.microsoft.com/Forums/windows/en-US/… - Marilee Turscak - MSFT
Hi Marilee, Thanks for your quick response, the given link describing more about the multi tenant problem. Could please point me the exact place look in to it. I have tried below code to refresh the token it throws error "Failed to acquire token silently as no token was found in the cache. Call method AcquireToken" cac = new ClientAssertionCertificate(clientId, cert); AuthenticationContext authenticationContext = new AuthenticationContext(authApiUri); authenticationResult = await authenticationContext.AcquireTokenSilentAsync(resourceServerName, cac, UserIdentifier.AnyUser); Thanks - Mahendran P

1 Answers

0
votes

Please clarify how to refresh the token obtained by ClientAssertionCertificate.

Unfortunately, there is no refresh token returned by using clientAssertionCertificate. We could capture the request with fiddler.

enter image description here