/// <summary> /// Gets the API client details for the supplied token from the Admin database. /// </summary> /// <param name="token">The OAuth security token for which API client details should be retrieved.</param> /// <returns>A populated <see cref="ApiClientDetails"/> instance if the token exists; otherwise an unpopulated instance.</returns> public async Task <ApiClientDetails> GetClientDetailsForTokenAsync(string token) { if (!Guid.TryParse(token, out Guid tokenAsGuid)) { return(new ApiClientDetails()); } var tokenClientRecords = await _accessTokenClientRepo.GetClientForTokenAsync(tokenAsGuid); return(ApiClientDetails.Create(tokenClientRecords)); }
/// <summary> /// Loads the API client details for the supplied token from the Admin database. /// </summary> /// <param name="token">The OAuth security token for which API client details should be retrieved.</param> /// <returns>A populated <see cref="ApiClientDetails"/> instance.</returns> public async Task <ApiClientDetails> GetClientDetailsForTokenAsync(string token) { if (!Guid.TryParse(token, out Guid tokenAsGuid)) { return(new ApiClientDetails()); } // TODO SF ODS-3459: this ought to be running as an independent task, scheduled multiple times a day. await _accessTokenClientRepo.DeleteExpiredTokensAsync(); var clientForToken = await _accessTokenClientRepo.GetClientForTokenAsync(tokenAsGuid); return(ApiClientDetails.Create(clientForToken)); }