I am trying to authenticate the user while using Microsoft Graph and keep getting the error Failed to acquire token silently. Call method AcquireToken
.
Any ideas how to fix this?
try
{
AuthenticationResult result =
await authContext.AcquireTokenSilentAsync(SettingsHelper.GraphResourceId,
clientCredential,
userId);
return result.AccessToken;
}
// Unable to retrieve the access token silently.
catch (AdalException ex)
{
HttpContext.Current.Request.GetOwinContext().Authentication.Challenge(
new AuthenticationProperties() { RedirectUri = "/" },
OpenIdConnectAuthenticationDefaults.AuthenticationType);
throw new Exception(Resource.Error_AuthChallengeNeeded + $" {ex.Message}");
}