我试图通过以下方法获得PowerBI API的访问令牌,并为clientId、clientSecret、用户名和密码提供适当的输入,但我收到了坏请求,表示缺少所需的参数'grant_type'。
public static async Task<string> GetToken()
{
var client = new RestClient();
var url = "https://login.microsoftonline.com/common/oauth2/token"
var request = new RestRequest(url, Method.POST, DataFormat.Json);
var body = new
{
grant_type = "password",
client_id = "clientId",
client_secret = "clientSecret",
username = "user",
password = "password",
resource = "https://analysis.windows.net/powerbi/api"
};
request.AddJsonBody(body);
var response = await client.ExecutePostAsync(request);
return response.Content;
}
JSON身体出了什么问题还是完全不同?
https://stackoverflow.com/questions/59737244
复制相似问题