Blazor & WASM in combination to get statistics from Spotify API for performing the song analysis. With separate microservices for auth, Spotify, user data tracking, and application, connected through gRPC with Polly.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SearchService.cs 1.3KB

1234567891011121314151617181920212223242526272829303132333435
  1. using SpotifyService.Protos;
  2. using Grpc.Core;
  3. using System.Text.Json;
  4. using SpotifyService.Contracts;
  5. namespace SpotifyService.Services
  6. {
  7. public class SearchService : Search.SearchBase
  8. {
  9. private readonly IHttpClientFactory _httpClientFactory;
  10. public SearchService(IHttpClientFactory httpClientFactory)
  11. {
  12. _httpClientFactory = httpClientFactory;
  13. }
  14. public override async Task<SearchForItemResponse> SearchForItem(SearchForItemRequest request, ServerCallContext context)
  15. {
  16. var httpClient = _httpClientFactory.CreateClient();
  17. httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "BQB7gF3eqg3xxqizhCuto24OgIbr_RFE6u6RJj30gHF7urqm2A0Q9venGsRXUlVuUSNOxdiG-8qb8Qp9_7luX_FqgrLswcnkgvtjm5toGR81HW-Dedul0E-K1OFc4sHz_iFsCN5QwBvIKqJjWmb6fioK4AZxp1N268WcoXzvW2LX9dv1gd6w-zSV");
  18. var responseText = await httpClient.GetStringAsync($"https://api.spotify.com/v1/search?q={request.Query}&type={request.Type}");
  19. var tracks = JsonSerializer.Deserialize<SearchContracts>(responseText);
  20. Console.WriteLine(tracks);
  21. //return new SearchForItemResponse
  22. //{
  23. // Tracks = tracks!.Tracks
  24. //};
  25. return null;
  26. }
  27. }
  28. }