これは私がコードを書かれており、出力を取得しようとしている方法ですEX = { "AADSTS70002:リクエストボディには、次のパラメータが含まれている必要があります。『client_secretまたはclient_assertion』
リクエストボディには、次のものが含まれている必要がありますパラメータ:あなたが認証するためのユーザ名とパスワードを使用してWebアプリケーション/ APIを使用しているようで、あなたのコードによると、
client_secret
またはclient_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);
}
return result;
}