public async Task <CertificateStatus> GetCertificate(string clientAssertion, string certificateHash) { var accessToken = await _tokenClient .GetAccessToken(_schemeOwnerBaseUrl, _clientId, clientAssertion) .ConfigureAwait(false); return(await GetCertificateStatus(accessToken, certificateHash).ConfigureAwait(false)); }
public async Task <(IToken Token, ResultState ResultState)> GetAccessToken(string corpId, string secret) { var cacheKey = GetTokenCachingKey(corpId, secret); var cacheToken = await _cache.GetStringAsync(cacheKey); if (cacheToken != null) { var token = JsonConvert.DeserializeObject <AccessToken>(cacheToken); if (IsExpired(token)) { return(token, ResultState.OkFromCache); } } var resp = await _tokenClient.GetAccessToken(corpId, secret); var result = await resp.ReadAsResult <AccessToken>(); if (result.State.Successed) { await _cache.SetStringAsync(cacheKey, JsonConvert.SerializeObject(result.Payload)); } return(result); }
public async Task <(AccessToken AccessToken, ResultState ResultState)> GetAccessToken(string appId, string appSecret) { var cacheToken = await _cache.GetStringAsync(appId); if (cacheToken != null) { var token = JsonConvert.DeserializeObject <AccessToken>(cacheToken); if (token.CreateUtcTime + token.ExpiresIn > DateTime.UtcNow - TimeSpan.FromMinutes(-5)) { return(token, ResultState.OkFromCache); } } var resp = await _tokenClient.GetAccessToken(appId, appSecret); var result = await resp.ReadAsResult <AccessToken>(); if (result.State.Successed) { await _cache.SetStringAsync(appId, JsonConvert.SerializeObject(result.Payload)); } return(result); }
private async Task <string> GetAccessToken(ClientAssertion clientAssertion) { var assertion = new TokenClient.Models.ClientAssertion { Subject = _partyDetailsOptions.ClientId, Issuer = _partyDetailsOptions.ClientId, Audience = _schemeOwnerClientOptions.ClientId, JwtId = clientAssertion.JwtId, IssuedAt = clientAssertion.IssuedAt, Expiration = clientAssertion.Expiration }; return(await _tokenClient.GetAccessToken( _schemeOwnerClientOptions.BaseUri, _partyDetailsOptions.ClientId, assertion)); }
private async Task <string> GetAccessToken(ClientAssertion clientAssertion) { var assertion = new TokenClient.Models.ClientAssertion { Subject = _partyDetailsOptions.ClientId, Issuer = _partyDetailsOptions.ClientId, Audience = _authorizationRegistryClientOptions.ClientId, JwtId = clientAssertion.JwtId, IssuedAt = clientAssertion.IssuedAt, Expiration = clientAssertion.Expiration }; var accessToken = await _tokenClient .GetAccessToken(_authorizationRegistryClientOptions.BaseUri, _partyDetailsOptions.ClientId, assertion); return(accessToken); }
private async Task <string> GetAccessToken(ClientAssertion clientAssertion) { var authorityAudience = $"{_authorizationRegistryBaseUrl}connect/token"; var assertion = new TokenClient.ClientAssertion { Subject = _clientId, Issuer = _clientId, Audience = _clientId, AuthorityAudience = authorityAudience, JwtId = clientAssertion.JwtId, IssuedAt = clientAssertion.IssuedAt, Expiration = clientAssertion.Expiration }; var accessToken = await _tokenClient .GetAccessToken(_authorizationRegistryBaseUrl, _clientId, assertion, _privateKey, _publicKeys) .ConfigureAwait(false); return(accessToken); }