Skip to content

Commit 78b5868

Browse files
committed
Injecting AuthenticationTokenProvier into HttpRequestManager
1 parent 46a3695 commit 78b5868

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

PowerDms.Api.Rest.Client/PowerDms.Api.Rest.Client/AuthenticationTokenProvider.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ public class AuthenticationTokenProvider : IAuthenticationTokenProvider
99
{
1010
private readonly OAuthClient _OAuthClient;
1111

12+
private readonly string _OAuthClientSecret;
13+
1214
private IDictionary<Credentials, string> _CachedCredentials;
1315

14-
public AuthenticationTokenProvider(OAuthClient oAuthClient)
16+
public AuthenticationTokenProvider(
17+
OAuthClient oAuthClient,
18+
string oAuthClientSecret)
1519
{
1620
_OAuthClient = oAuthClient;
21+
_OAuthClientSecret = oAuthClientSecret;
1722
_CachedCredentials = new Dictionary<Credentials, string>();
1823
}
1924

@@ -28,7 +33,7 @@ public async Task<string> GetAccessToken(Credentials credentials)
2833
credentials.Username,
2934
credentials.Password,
3035
credentials.SiteKey,
31-
credentials.ClientSecret
36+
_OAuthClientSecret
3237
)).GetContent<string>();
3338
}
3439
}

PowerDms.Api.Rest.Client/PowerDms.Api.Rest.Client/HttpRequestManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ public class HttpRequestManager
1313
private readonly IAuthenticationTokenProvider _AuthenticationTokenProvider;
1414

1515
public HttpRequestManager(
16-
HttpClient httpClient)
16+
HttpClient httpClient,
17+
AuthenticationTokenProvider authenticationTokenProvider)
1718
{
1819
_HttpClient = httpClient;
1920
PowerDmsRestApiClient = new PowerDmsRestApiClient(httpClient);
20-
_AuthenticationTokenProvider = new AuthenticationTokenProvider(
21-
PowerDmsRestApiClient.OAuth);
21+
_AuthenticationTokenProvider = authenticationTokenProvider;
2222
}
2323

2424
public async Task<HttpResponseMessage> SendAsync<T>(HttpRequestBuilder<T> httpRequestBuilder)

PowerDms.Api.Rest.Client/PowerDms.Api.Rest.Client/PowerDms.Api.Rest.Client.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
</ItemGroup>
1010

1111
<ItemGroup>
12-
<ProjectReference Include="..\..\..\PowerDMS\tests\services\api\PowerDms.Api.Rest.Dtos\PowerDms.Api.Rest.Dtos.csproj" />
1312
<ProjectReference Include="..\PowerDms.Api.Rest.Dto\PowerDms.Api.Rest.Dto.csproj" />
1413
</ItemGroup>
1514

PowerDms.Api.Rest.Client/PowerDms.Api.Rest.Client/RestApiRoutes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
public class RestApiRoutes
44
{
5-
public const string PowerDmsRestApiDomain = "api.powerdms.com";
5+
public const string PowerDmsRestApiDomain = "https://api.powerdms.com";
66

77
public const string Groups = "/principal/groups";
88

0 commit comments

Comments
 (0)