Created
July 9, 2020 01:29
-
-
Save xximjasonxx/9054b3493b8d39e3fbf3c7ab6072acd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var client = new HttpClient()) | |
{ | |
client.BaseAddress = new System.Uri("https://<your tenant>.auth0.com/"); | |
var response = await client.PostAsync("oauth/token", new FormUrlEncodedContent( | |
new Dictionary<string, string> | |
{ | |
{ "grant_type", "client_credentials" }, | |
{ "client_id", "<client_id>" }, | |
{ "client_secret", "<client_secret>" }, | |
{ "audience", "https://<your tenant>.auth0.com/api/v2/" } | |
} | |
)); | |
var content = await response.Content.ReadAsStringAsync(); | |
var jsonResult = JObject.Parse(content); | |
var mgmtToken = jsonResult["access_token"].Value<string>(); | |
using (var mgmtClient = new ManagementApiClient(mgmtToken, new System.Uri("https://<your tenant>.auth0.com/api/v2"))) | |
{ | |
return await mgmtClient.Users.GetAsync(userId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment