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个字符

AuthProvider.cs 794B

1234567891011121314151617181920212223242526
  1. using Blazored.SessionStorage;
  2. using System.Security.Claims;
  3. namespace NemAnBlazor
  4. {
  5. public class AuthProvider : AuthenticationStateProvider
  6. {
  7. private readonly ISessionStorageService _sessionStorage;
  8. public AuthProvider(ISessionStorageService sessionStorage)
  9. {
  10. _sessionStorage = sessionStorage;
  11. }
  12. public override async Task<AuthenticationState> GetAuthenticationStateAsync()
  13. {
  14. string token = await _sessionStorage.GetItemAsync<string>("token");
  15. ClaimsIdentity identity = new ();
  16. ClaimsPrincipal user = new (identity);
  17. AuthenticationState state = new(user);
  18. NotifyAuthenticationStateChanged(Task.FromResult(state));
  19. return state;
  20. }
  21. }
  22. }