Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save himadric/25b9cd103deb924aa782bfc566c9e571 to your computer and use it in GitHub Desktop.
Save himadric/25b9cd103deb924aa782bfc566c9e571 to your computer and use it in GitHub Desktop.
[Authorize]
public async Task<IActionResult> CallSitecoreApi()
{
var token = await HttpContext.GetTokenAsync("access_token");
var client = _httpClientFactory.CreateClient();
client.SetBearerToken(token);
var response = await client.GetStringAsync(Constants.SitecoreApi + "sitecorelayout");
var obj = JsonConvert.DeserializeObject(response);
ViewBag.Json = JsonConvert.SerializeObject(obj, Formatting.Indented);
return View();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment