public async Task <TokenClaim> ApplyToken() { var content = new MultipartFormDataContent(); foreach (var item in AuthoritionTicket) { content.Add(new StringContent(item.Value), item.Key); } var response = await DependenceInjectService.GetService <IHttpClientFactory>().SendAsync(AuthorityServer, content); var Claim = new TokenClaim { Raw = await response.Content.ReadAsStringAsync() }; var json = JObject.Parse(Claim.Raw); Claim.Token = Credential.Invoke(json, CredentialKey); var ExpireSecond = ExpireTime.Invoke(json, ExpireTimeKey); if (ExpireSecond > 0) { Claim.Expires = DateTime.Now.AddSeconds(ExpireSecond); } return(Claim); }
public async Task<TokenClaim> ApplyToken() { TimeSpan spend = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); if (Mode == GAMode.RemoteAccess) { var response = await DependenceInjectService.GetService<IHttpClientFactory>().SendAsync(AuthorityServer, null, HttpMethod.Get); var Claim = new TokenClaim(); Claim.Raw = Claim.Token = await response.Content.ReadAsStringAsync(); Claim.Expires = DateTime.Now.AddSeconds(spend.TotalSeconds % ExpireSecond); return Claim; } else if (Mode == GAMode.Generation) return GetCodeInternal(SecretKey, spend); else throw new NotSupportedException("The authentication component has not been initialized yet. Please set the server address or Secretkey."); }
public static IFastDFSService GetService() => DependenceInjectService.GetService <IFastDFSService>();