【发布时间】:2017-08-10 05:49:43
【问题描述】:
如何在我的控制台应用程序中针对 Azure Active Directory 对用户进行身份验证,而不重定向到登录页面?
string tenantName = "---";
string authString = "https://login.microsoftonline.com/" + tenantName;
AuthenticationContext authenticationContext = new AuthenticationContext(authString, false);
// Config for OAuth client credentials
string clientId = "---";
string key = "---";
ClientCredential clientCred = new ClientCredential(clientId, key);
string resource = "https://pwsintsnapitazure.azurewebsites.net";
string token;
AuthenticationResult authenticationResult = authenticationContext.AcquireTokenAsync(resource, clientCred).Result;
token = authenticationResult.AccessToken;
【问题讨论】:
-
当我尝试上面的示例代码时,我得到了错误“ex = {”AADSTS70002:请求正文必须包含以下参数:'client_secret or client_assertion"
-
RequestMessage = {方法:POST,RequestUri:'login.microsoftonline.com/142d56e1-4ab5-4f5d-8140-d3db9fbf4cac/…?',版本:1.1,内容:System.Net.Http.StringContent,标头:{接受:应用程序/x-www-form -urlencoded Content-Type: application/x-...
-
在您的新帖子中查看我的回复:*.com/questions/45609432/…
标签: c# azure azure-active-directory