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.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SpotifyHelper.cs 887B

123456789101112131415161718192021222324252627282930
  1. using GrpcShared.DTO;
  2. using GrpcShared.DTO.Db;
  3. using GrpcShared.Interfaces;
  4. using NemAnBlazor.Services.Interfaces;
  5. namespace SpotifyService
  6. {
  7. public static class SpotifyHelper
  8. {
  9. public static async Task<string?> TryRefreshToken
  10. (IAuthService authService,
  11. UserResponse user,
  12. IIdentityService identityService)
  13. {
  14. var refreshResponse = await authService.RefreshAccessToken(user);
  15. if (refreshResponse.AccessToken != null)
  16. {
  17. await identityService.UpdateTokenAsync(new UserResponse
  18. {
  19. Id = user.Id,
  20. Token = refreshResponse.AccessToken,
  21. RefreshToken = user.RefreshToken
  22. });
  23. return refreshResponse.AccessToken;
  24. }
  25. else return null;
  26. }
  27. }
  28. }