This commit is contained in:
		
							parent
							
								
									d1e217329a
								
							
						
					
					
						commit
						9df5750f1c
					
				| @ -10,6 +10,7 @@ namespace OpenHarbor.JwtTokenManager; | |||||||
| public class JwtTokenManagerService(JwtTokenManagerOptions options, IHttpClientFactory httpClientFactory, ILogger<JwtTokenManagerService>? logger, IMemoryCache? memoryCache, JwtTokenManagerCacheOptions cacheOptions)  | public class JwtTokenManagerService(JwtTokenManagerOptions options, IHttpClientFactory httpClientFactory, ILogger<JwtTokenManagerService>? logger, IMemoryCache? memoryCache, JwtTokenManagerCacheOptions cacheOptions)  | ||||||
|     : IJwtTokenManagerService |     : IJwtTokenManagerService | ||||||
| { | { | ||||||
|  |   private readonly HttpClient _httpClient = httpClientFactory.CreateClient(); | ||||||
|   private readonly TimeSpan _cacheExpirationOffset = TimeSpan.FromSeconds(cacheOptions.ExpirationOffset); |   private readonly TimeSpan _cacheExpirationOffset = TimeSpan.FromSeconds(cacheOptions.ExpirationOffset); | ||||||
|   private readonly string _scopes = string.Join(" ", options.Scopes); |   private readonly string _scopes = string.Join(" ", options.Scopes); | ||||||
|    |    | ||||||
| @ -30,8 +31,6 @@ public class JwtTokenManagerService(JwtTokenManagerOptions options, IHttpClientF | |||||||
|       } |       } | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     var client = httpClientFactory.CreateClient(); |  | ||||||
| 
 |  | ||||||
|     var formContent = new FormUrlEncodedContent([ |     var formContent = new FormUrlEncodedContent([ | ||||||
|       new KeyValuePair<string, string>("grant_type", "client_credentials"), |       new KeyValuePair<string, string>("grant_type", "client_credentials"), | ||||||
|       new KeyValuePair<string, string>("client_id", options.ClientId), |       new KeyValuePair<string, string>("client_id", options.ClientId), | ||||||
| @ -46,7 +45,7 @@ public class JwtTokenManagerService(JwtTokenManagerOptions options, IHttpClientF | |||||||
|      |      | ||||||
|     request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); |     request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); | ||||||
|      |      | ||||||
|     var response = await client.SendAsync(request, cancellationToken); |     var response = await _httpClient.SendAsync(request, cancellationToken); | ||||||
|      |      | ||||||
|     response.EnsureSuccessStatusCode(); |     response.EnsureSuccessStatusCode(); | ||||||
|      |      | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user