我试图使用HttpClient请求获得Auth0管理API访问令牌,但获得禁止403错误。我还尝试使用c#和Rest api的Auth0管理api sdk调用api,仍然得到错误。谁能指导我如何从Auth0获得管理API的访问令牌?
下面的代码我尝试使用HttpClient
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://{your domain}/");
var response = await client.PostAsync("oauth/token",
new FormUrlEncodedContent(new Dictionary<string, string>
{
{ "grant_type", "clent_credentials" },
{ "client_id", "{client_Id}" },
{ "client_secret", "{client_secret}" },
{ "audience", "https://{your domain}/api/v2/" }
}));
var content = await response.Content.ReadAsStringAsync();
var jsonResult = JObject.Parse(content);
}
反应:StatusCode: 403
ReasonParse: 'Forbidden'
我也尝试过使用rest客户端进行授权调用,如下所示
RestClient client1 = new RestClient("https://{your domain}/authorize");
var request = new RestRequest();
request.Method = Method.Post;
request.AddParameter(
"application/x-www-form-urlencoded",
"grant_type=clent_credentials&client_id={client_Id}&
client_secret={client_secret}&
audience=https://{your domain}/api/v2/", ParameterType.RequestBody);
var response1 = await client1.ExecuteAsync(request);
反应:状态码:not found
内容类型:text/plainfont - family:宋体
我想从Auth0获得访问管理API的访问令牌。
您的请求参数"{"grant_type", ">clent_credentials";}";"我如果客户端中缺少,则应该是{"grant_type", "client_credential "},