Hi,
I’m a college computer science student who is currently using Auth0 as a means for user authentication, so apologies for any misunderstandings (I am very inexperienced) on my behalf.
I would like to use the Auth0 Management API to update metadata for my teams’ users. I’m trying to obtain authorized access from the Management API, and am running into errors with sending a generated access token to the API - I keep getting an [unauthorized] response from the API upon sending the request. I’m generating the access token fine and it appears to be in jwt format. My code closely resembles the provided C# code in the tutorial with test connections.
public async Task<string> receiveAuth0Token() {
var client = new RestClient("https://tigertix.us.auth0.com/oauth/token");
var request = new RestRequest();
request.Method = Method.Post;
request.AddHeader("content-type", "application/json");
request.AddJsonBody(new {
client_id = "XXXXXXXXXXXXXXX",
client_secret = "XXXXXXXXXXXXXXXXXX",
audience = "https://tigertix.us.auth0.com/api/v2/",
grant_type = "client_credentials"
});
var response = await client.ExecuteAsync(request);
var test = response.Content.FromJson<object>();
Dictionary<string, object> response1 = ((Dictionary<string, object>)(test));
string token = (string)response1["access_token"];
return token;
}
public async void sendAuth0Token(string token) {
var client = new RestClient("https://tigertix.us.auth0.com/api/");
var request = new RestRequest();
request.Method = Method.Get;
request.AddHeader("authorization", "Bearer " + token);
var response = await client.ExecuteAsync(request);
}
Any help would be much appreciated, thanks in advance!
EDIT: I believe the first snippet of code works fine, as the token is generated successfully in jwt format.