private async Task <AuthorizationToken> GetAuthorizationTokenAsync() { var secret = await secretsService .GetSecretAsync(nameof(AuthenticationService)) .ConfigureAwait(false); if (string.IsNullOrEmpty(secret)) { return(null); } var token = JsonConvert.DeserializeObject <AuthorizationToken>(secret); if (token.AccessTokenExpires.GetValueOrDefault(DateTime.UtcNow).AddMinutes(-1) < DateTime.UtcNow) { token = await AuthorizationHandler .RefreshAsync(token) .ConfigureAwait(false); await((IAuthenticationSetup)this) .SetupAsync(token) .ConfigureAwait(false); } return(token); }
public async Task <IActionResult> GetSecret([FromRoute] string secretName, [FromRoute] string secretVersion) { var secret = await _secretsService.GetSecretAsync(secretName, secretVersion); if (secret is null) { return(StatusCode(StatusCodes.Status404NotFound, "Not Found")); } return(Ok(secret)); }