小编rav*_*hod的帖子

ex = {"AADSTS70002:请求正文必须包含以下参数:'client_secret或client_assertion'

这就是我编写代码并尝试获取输出的方法.

请求正文必须包含以下参数:client_secretclient_assertion

 static async Task<AuthenticationResult> getAccessToken()
 {
     string hardcodedUsername = "";
     string hardcodedPassword = "";
     string tenantName = "projectwidgets.com";
     string authString = "https://login.microsoftonline.com/" + tenantName;
     AuthenticationContext authenticationContext = new AuthenticationContext(authString, false);
     //Config for OAuth client credentials
     string clientId = "as";
     string key = "kk";
     string authority = String.Format(CultureInfo.InvariantCulture, aadInstance, tenantName);
     var authContext = new AuthenticationContext(authority);
     AuthenticationResult result = null;
     try
     {
         result = await authContext.AcquireTokenAsync("https://pwsnapitazure.azurewebsites.net", clientId, new UserPasswordCredential(hardcodedUsername, hardcodedPassword));
     }
     catch (Exception ex)
     {
          Console.WriteLine(ex.StackTrace);
          System.Diagnostics.Debug.WriteLine(ex.Message);
     } …
Run Code Online (Sandbox Code Playgroud)

c# azure-active-directory

8
推荐指数
2
解决办法
9433
查看次数

标签 统计

azure-active-directory ×1

c# ×1