我想在使用Microsoft Graph的情况下对用户进行身份验证,并不断收到错误Failed to acquire token silently. Call method AcquireToken
。无法默认获取令牌。调用方法AcquireToken
任何想法如何解决这个问题?
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}");
}