Auth0 Home Blog Docs

Delete current user

jwt
auth0
api
scopes
login

#1

Hi,

in my application, the user should be able to auto delete itself.

The code I use is:

using (var client = new HttpClient())
{

_ Configuration = builder.Build();_
_ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(“Bearer”, tok);_

_ client.BaseAddress = new Uri(Configuration[“Auth0:BaseAddress”]);_
_ var result = await client.DeleteAsync("/api/v2/users/" + auth0ID);_
_ string resultContent = await result.Content.ReadAsStringAsync();_
_ var resource = JObject.Parse(resultContent);_
}

If I understood well, this code needs delete:users or delete:current_user.

I tried some stuff, but I’m getting a list of different errors.

  1. If I set as audience the auth0 system api, I see a lot of scope in the list, but not what I need (as wrote above)
  2. If I use custom API and create delete:users and delete:current_user, I can see them in the jwt token, but I am NOT authorized to all my others APIs I already wrote (I’m working with C# and I use the decorator [Authorize])

How can I reach my goal? I need to add those scopes to all my users and not affecting what is already working.