diff --git a/IdentityServer.Wrapper/IdentityServer.Wrapper.csproj b/IdentityServer.Wrapper/IdentityServer.Wrapper.csproj
index a69da54..d8adc1a 100644
--- a/IdentityServer.Wrapper/IdentityServer.Wrapper.csproj
+++ b/IdentityServer.Wrapper/IdentityServer.Wrapper.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/IdentityServer.Wrapper/Services/IdentityService.cs b/IdentityServer.Wrapper/Services/IdentityService.cs
index 88fbc9b..c118797 100644
--- a/IdentityServer.Wrapper/Services/IdentityService.cs
+++ b/IdentityServer.Wrapper/Services/IdentityService.cs
@@ -1,11 +1,10 @@
using IdentityServer.PublishedLanguage.Dto;
using IdentityServer.Wrapper.Constants;
using IdentityServer.Wrapper.Models;
-using Newtonsoft.Json;
+using NDB.Extensions.Http;
using System;
using System.Net.Http;
using System.Net.Http.Headers;
-using System.Text;
using System.Threading.Tasks;
namespace IdentityServer.Wrapper.Services
@@ -26,55 +25,15 @@ namespace IdentityServer.Wrapper.Services
public async Task Authenticate(string userName, string password)
{
var route = string.Format(ApiRoutes.Authentication, userName, password);
- var result = await ExecutePostRequest(route);
+ var result = await _httpClient.ExecutePostRequest(route);
return result;
}
public async Task Authorize(string token)
{
var route = string.Format(ApiRoutes.Authorization, token);
- var result = await ExecutePostRequest(route);
+ var result = await _httpClient.ExecutePostRequest(route);
return result;
}
-
- #region Private methods
- private async Task ExecuteGetRequest(string route) where T : class
- {
- using (var response = await _httpClient.GetAsync(route))
- {
- if (!response.IsSuccessStatusCode)
- throw new Exception($"Error: StatusCode: {response.StatusCode}; Reason: {response.ReasonPhrase}");
-
- var result = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync());
- return result;
- }
- }
-
- private async Task ExecutePostRequest(string route) where R : class
- {
- HttpContent content = new StringContent(JsonConvert.SerializeObject(string.Empty), Encoding.UTF8, _contentType);
- using (var response = await _httpClient.PostAsync(route, content))
- {
- if (!response.IsSuccessStatusCode)
- throw new Exception($"Error: StatusCode: {response.StatusCode}; Reason: {response.ReasonPhrase}");
-
- var result = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync());
- return result;
- }
- }
-
- private async Task ExecutePostRequest(string route, B body) where R : class where B : class
- {
- HttpContent content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, _contentType);
- using (var response = await _httpClient.PostAsync(route, content))
- {
- if (!response.IsSuccessStatusCode)
- throw new Exception($"Error: StatusCode: {response.StatusCode}; Reason: {response.ReasonPhrase}");
-
- var result = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync());
- return result;
- }
- }
- #endregion
}
}