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.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

StatsService.cs 985B

1234567891011121314151617181920212223242526272829303132
  1. using GrpcShared.DTO;
  2. using GrpcShared.DTO.Track;
  3. using GrpcShared.Interfaces;
  4. using Microsoft.Net.Http.Headers;
  5. using Newtonsoft.Json;
  6. namespace SpotifyService.Services
  7. {
  8. public class StatsService : IStatsService
  9. {
  10. private readonly IHttpClientFactory _httpClientFactory;
  11. public StatsService(IHttpClientFactory httpClientFactory)
  12. {
  13. _httpClientFactory = httpClientFactory;
  14. }
  15. public async Task<CurrentTrackResponse> GetCurrentlyPlayingTrack(TokenMessage token)
  16. {
  17. var client = _httpClientFactory.CreateClient("HttpClient");
  18. client.DefaultRequestHeaders.Add(HeaderNames.Authorization, "Bearer " + token.Token);
  19. var searchResult = await client.GetAsync($"me/player/currently-playing");
  20. var responses = JsonConvert.DeserializeObject<CurrentTrackResponse>(await searchResult.Content.ReadAsStringAsync())!;
  21. return responses;
  22. }
  23. }
  24. }