Added userinfo endpoint usage and api now properly creates necessary claims to start doing database stuff
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using WebAPI.Data.Dto.OIDC;
|
||||
|
||||
namespace WebAPI.Data
|
||||
{
|
||||
@@ -49,6 +50,21 @@ namespace WebAPI.Data
|
||||
var responsecontent = await response.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<IntrospectionResponse>(responsecontent).Active;
|
||||
}
|
||||
|
||||
public async Task<OIDCUserInfoResponse> GetTokenDetails(string accessToken)
|
||||
{
|
||||
HttpRequestMessage requestMessage =
|
||||
new HttpRequestMessage(HttpMethod.Get, $"https://{AppSettings.OIDCUserInfoEndpoint}");
|
||||
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
|
||||
HttpResponseMessage response = await _httpClient.SendAsync(requestMessage);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var responsecontent = await response.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<OIDCUserInfoResponse>(responsecontent);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user