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 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. @page "/"
  2. @using Grpc.Net.Client
  3. @using Grpc.Net.Client.Web
  4. @using GrpcShared
  5. @using GrpcShared.DTO.Auth
  6. @using GrpcShared.DTO.Search
  7. @using NemAnBlazor.Services.Interfaces
  8. @inject NavigationManager NavigationManager
  9. @inject IAuthClientService AuthService
  10. @inject ITrackClientService SearchService
  11. @using System.Security.Claims
  12. @inject Blazored.LocalStorage.ILocalStorageService localStorage
  13. <AuthorizeView>
  14. <Authorized>
  15. <p>Dobrodosli @context.User.Claims.FirstOrDefault(x => x.Type == "name")?.Value.ToUpper()</p>
  16. </Authorized>
  17. <NotAuthorized>
  18. Nisi autorizovan.
  19. <button class="btn btn-primary" @onclick="LoginUser">Login</button>
  20. </NotAuthorized>
  21. </AuthorizeView>
  22. <PageTitle>Index</PageTitle>
  23. <h1>Pozdrav Diligent!</h1>
  24. Dobrodošli u našu NemAn aplikaciju.
  25. @code {
  26. protected override async Task OnInitializedAsync()
  27. {
  28. var userId = await localStorage.GetItemAsync<string>("user_info");
  29. if (userId != null) NavigationManager.NavigateTo("/home");
  30. }
  31. private async Task LoginUser()
  32. {
  33. //var response = await SearchService.GetListSearchAsync(new GrpcShared.DTO.Search.SearchRequest() { Query="venom", Type = "track"});
  34. CodeRequest authParams = await AuthService.GetAuthParams();
  35. // await AuthService.GetAccessToken(new CodeResponse{ Code = "hello"});
  36. string url = $"https://accounts.spotify.com/en/authorize?client_id={authParams.ClientId}&redirect_uri={authParams.RedirectURI}&response_type={authParams.ResponseType}&scope={authParams.Scope}&show_dialog={authParams.ShowDialog}";
  37. NavigationManager.NavigateTo(url);
  38. }
  39. }