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

Callback.razor 965B

123456789101112131415161718192021222324252627282930313233
  1. @page "/callback"
  2. @using NemAnBlazor.Services.Interfaces
  3. @inject NavigationManager NavigationMgr
  4. @inject IAuthClientService AuthService
  5. @inject Blazored.SessionStorage.ISessionStorageService sessionStorage
  6. <PageTitle>Redirecting...</PageTitle>
  7. <p role="status">Loading...</p>
  8. @code {
  9. protected override async Task OnInitializedAsync()
  10. {
  11. string url = NavigationMgr.Uri;
  12. //code is the only parameter in the url
  13. string code = url.Split("=")[1];
  14. var response = await AuthService.GetAccessToken(new GrpcShared.DTO.Auth.TokenRequest { code = code});
  15. //if (response.access_token == null) NavigationMgr.NavigateTo("/");
  16. //store access token in local storage
  17. await sessionStorage.SetItemAsync("token", response.access_token);
  18. await sessionStorage.SetItemAsync("refresh_token", response.refresh_token);
  19. //redirect to home
  20. NavigationMgr.NavigateTo("/home");
  21. }
  22. }