@page @using Microsoft.AspNetCore.Authentication @using System.Net.Http.Headers @using System.Text.Json @model IndexModel @{ ViewData["Title"] = "Home page"; }
HttpContext.GetTokenAsync("access_token")
@await HttpContext.GetTokenAsync("access_token")
@{
var apiResponse = response.StatusCode.ToString();
if (response.IsSuccessStatusCode)
{
apiResponse = JsonSerializer.Serialize(JsonDocument.Parse(await response.Content.ReadAsStringAsync()), new JsonSerializerOptions
{
WriteIndented = true
});
}
}
@apiResponse;
request = new HttpRequestMessage(HttpMethod.Get, "https://localhost:44301/api/claims");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", await HttpContext.GetTokenAsync("access_token"));
response = await client.SendAsync(request);
@{
apiResponse = response.StatusCode.ToString();
if (response.IsSuccessStatusCode)
{
apiResponse = JsonSerializer.Serialize(JsonDocument.Parse(await response.Content.ReadAsStringAsync()), new JsonSerializerOptions
{
WriteIndented = true
});
}
}
@apiResponse;
}