Once a user has logged in I’m trying to let them add an Organisation properly against their username in Auth0. I have written this quick test method:
[Authorize]
public async Task<IActionResult> UpdateProfile()
{
var userId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;
var client = new ManagementApiClient(await GenerateManagementApiToken(), new Uri($"https://{_configuration["Authentication:Auth0:Domain"]}"));
var user = await client.Users.GetAsync(userId);
Auth0UserMetaData metadata = Auth0UserMetaData.FromJSON(user.UserMetadata);
metadata.OrganisationId = "123456";
var response = await client.Users.UpdateAsync(userId, new Auth0.ManagementApi.Models.UserUpdateRequest
{
UserMetadata = metadata.ToJSON()
});
return View();
}
This returns an error that it cannot get the user. I don’t know what userid
should be?