diff --git a/Src/Dlhis.ScheduledTask/SyncSapInfo/Services/IJinkoJIPService.cs b/Src/Dlhis.ScheduledTask/SyncSapInfo/Services/IJinkoJIPService.cs index 6d7917bc..fad41965 100644 --- a/Src/Dlhis.ScheduledTask/SyncSapInfo/Services/IJinkoJIPService.cs +++ b/Src/Dlhis.ScheduledTask/SyncSapInfo/Services/IJinkoJIPService.cs @@ -7,4 +7,6 @@ public interface IJinkoJIPService : ISingletonDependency Task UploadAttendancesAsync(List requests); Task SyncMealSupplementRecordsAsync(List requests); + + public string IssueToken(); } diff --git a/Src/Dlhis.ScheduledTask/SyncSapInfo/Services/Implements/JinkoJIPService.cs b/Src/Dlhis.ScheduledTask/SyncSapInfo/Services/Implements/JinkoJIPService.cs index eb9a1a3c..1142885d 100644 --- a/Src/Dlhis.ScheduledTask/SyncSapInfo/Services/Implements/JinkoJIPService.cs +++ b/Src/Dlhis.ScheduledTask/SyncSapInfo/Services/Implements/JinkoJIPService.cs @@ -26,10 +26,8 @@ public class JinkoJIPService : IJinkoJIPService { var httpClient = _httpClientFactory.CreateClient(); httpClient.BaseAddress = new Uri(_configuration.GetSection("JinkoOptions:Jip:BaseUrl").Value); - //httpClient.Timeout = TimeSpan.FromMinutes(10); - var key = _configuration.GetSection("JinkoOptions:Jip:Key").Value; - var secret = _configuration.GetSection("JinkoOptions:Jip:Secret").Value; - httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", IssueJwt(key, secret, 5)); + + httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", IssueToken()); return httpClient; } @@ -85,12 +83,12 @@ public class JinkoJIPService : IJinkoJIPService return responseJson; } - - //********************************************************************* help methods ***************************************************************************/ - - - private static string IssueJwt(string jwtKey, string jwtSecret, int mins) + public string IssueToken() { + var jwtKey = _configuration.GetSection("JinkoOptions:Jip:Key").Value; + var jwtSecret = _configuration.GetSection("JinkoOptions:Jip:Secret").Value; + var mins = 5; + var now = DateTime.Now.AddMinutes(-mins); var expires = DateTime.Now.AddMinutes(mins);