using SpotifyService.Protos; using Grpc.Core; using System.Text.Json; using SpotifyService.Contracts; namespace SpotifyService.Services { public class SearchService : Search.SearchBase { private readonly IHttpClientFactory _httpClientFactory; public SearchService(IHttpClientFactory httpClientFactory) { _httpClientFactory = httpClientFactory; } public override async Task SearchForItem(SearchForItemRequest request, ServerCallContext context) { var httpClient = _httpClientFactory.CreateClient(); httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "BQB7gF3eqg3xxqizhCuto24OgIbr_RFE6u6RJj30gHF7urqm2A0Q9venGsRXUlVuUSNOxdiG-8qb8Qp9_7luX_FqgrLswcnkgvtjm5toGR81HW-Dedul0E-K1OFc4sHz_iFsCN5QwBvIKqJjWmb6fioK4AZxp1N268WcoXzvW2LX9dv1gd6w-zSV"); var responseText = await httpClient.GetStringAsync($"https://api.spotify.com/v1/search?q={request.Query}&type={request.Type}"); var tracks = JsonSerializer.Deserialize(responseText); Console.WriteLine(tracks); //return new SearchForItemResponse //{ // Tracks = tracks!.Tracks //}; return null; } } }