Hi All,
we have a MultiTenant Application & we are using Microsoft.IdentityModel.Clients.ActiveDirectory version 2.12.0.0.
when we try to acquire Silent toke we are getting exception. Below is the Exception -
Microsoft.IdentityModel.Clients.ActiveDirectory.AdalSilentTokenAcquisitionException: Failed to acquire token silently.
Below is the piece of code we have used to do this -
try{
//Get Auth Context.
AuthenticationContext authContext = new AuthenticationContext(string.Format(aadInstance, tenantId), new NaiveSessionCache(userObjectID));
//read certificate from store.
X509Certificate2 tokenCertificate = GetCertificateFromStore();
//Get Client Assertion Certificate.
ClientAssertionCertificate assertionCertificate = new ClientAssertionCertificate(clientId, tokenCertificate);
//Acuire Silent token.
AuthenticationResult result = authContext.AcquireTokenSilent(resourceId, assertionCertificate, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId));
//return access token.
if (result != null && !string.IsNullOrEmpty(result.AccessToken))
return result.AccessToken;
else
return null;
}
catch (AdalSilentTokenAcquisitionException ex)
{
throw ex;
}
Any help would be much appreciated.
Thanks,
Ritesh