@page "/" @using SpotifyAPI.Web @using System @using Microsoft.Extensions.Configuration @inject IConfiguration Configuration @inject NavigationManager navManager
SPOTIFY_CLIENT_ID: @(Configuration["SPOTIFY_CLIENT_ID"] ?? "Not set, example won't work")
@if (_isAuthed && _me != null) {
You have a grant total of @_totalPlaylistCount playlists!
} else { To get started: Login via Spotify } @code { private bool _isAuthed = false; private PrivateUser _me; private int _totalPlaylistCount; private Uri _authUri; protected override void OnInitialized() { if (!string.IsNullOrEmpty(Configuration["SPOTIFY_CLIENT_ID"])) { var baseUri = navManager.ToAbsoluteUri(navManager.BaseUri); var loginRequest = new LoginRequest(baseUri, Configuration["SPOTIFY_CLIENT_ID"], LoginRequest.ResponseType.Token) { Scope = new[] { Scopes.PlaylistReadPrivate, Scopes.PlaylistReadCollaborative } }; _authUri = loginRequest.ToUri(); } } protected override async Task OnInitializedAsync() { var uri = new Uri(navManager.Uri); var maxLen = Math.Min(1, uri.Fragment.Length); Dictionary