diff --git a/SpotifyAPI.Web.Examples/Example.ASPBlazor/Example.ASPBlazor.csproj b/SpotifyAPI.Web.Examples/Example.ASPBlazor/Example.ASPBlazor.csproj
index 92605c5a..f8ff38d1 100644
--- a/SpotifyAPI.Web.Examples/Example.ASPBlazor/Example.ASPBlazor.csproj
+++ b/SpotifyAPI.Web.Examples/Example.ASPBlazor/Example.ASPBlazor.csproj
@@ -4,4 +4,8 @@
netcoreapp3.1
+
+
+
+
diff --git a/SpotifyAPI.Web.Examples/Example.ASPBlazor/Pages/Counter.razor b/SpotifyAPI.Web.Examples/Example.ASPBlazor/Pages/Counter.razor
deleted file mode 100644
index 8641f781..00000000
--- a/SpotifyAPI.Web.Examples/Example.ASPBlazor/Pages/Counter.razor
+++ /dev/null
@@ -1,16 +0,0 @@
-@page "/counter"
-
-
Counter
-
-Current count: @currentCount
-
-
-
-@code {
- private int currentCount = 0;
-
- private void IncrementCount()
- {
- currentCount++;
- }
-}
diff --git a/SpotifyAPI.Web.Examples/Example.ASPBlazor/Pages/FetchData.razor b/SpotifyAPI.Web.Examples/Example.ASPBlazor/Pages/FetchData.razor
deleted file mode 100644
index 48ea25ee..00000000
--- a/SpotifyAPI.Web.Examples/Example.ASPBlazor/Pages/FetchData.razor
+++ /dev/null
@@ -1,46 +0,0 @@
-@page "/fetchdata"
-
-@using Example.ASPBlazor.Data
-@inject WeatherForecastService ForecastService
-
-Weather forecast
-
-This component demonstrates fetching data from a service.
-
-@if (forecasts == null)
-{
- Loading...
-}
-else
-{
-
-
-
- Date |
- Temp. (C) |
- Temp. (F) |
- Summary |
-
-
-
- @foreach (var forecast in forecasts)
- {
-
- @forecast.Date.ToShortDateString() |
- @forecast.TemperatureC |
- @forecast.TemperatureF |
- @forecast.Summary |
-
- }
-
-
-}
-
-@code {
- private WeatherForecast[] forecasts;
-
- protected override async Task OnInitializedAsync()
- {
- forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
- }
-}
diff --git a/SpotifyAPI.Web.Examples/Example.ASPBlazor/Pages/Index.razor b/SpotifyAPI.Web.Examples/Example.ASPBlazor/Pages/Index.razor
index e54d9143..8387e164 100644
--- a/SpotifyAPI.Web.Examples/Example.ASPBlazor/Pages/Index.razor
+++ b/SpotifyAPI.Web.Examples/Example.ASPBlazor/Pages/Index.razor
@@ -1,7 +1,61 @@
-@page "/"
+@page "/"
+@inject NavigationManager navManager
+@using SpotifyAPI.Web
Hello, world!
-Welcome to your new app.
+@if (_isAuthed && _me != null)
+{
+ Welcome @_me.DisplayName!
+
+ You have a grant toal of @_totalPlaylistCount playlists!
+
+}
+else
+{
+ To get started:
+
+ Login via Spotify
+
+}
-
+@code {
+ private Uri _authUri;
+
+ private bool _isAuthed;
+
+ private PrivateUser _me;
+
+ private int _totalPlaylistCount;
+
+ protected override void OnInitialized()
+ {
+ var clientId = Environment.GetEnvironmentVariable("SPOTIFY_CLIENT_ID");
+ var baseUri = navManager.ToAbsoluteUri(navManager.BaseUri);
+
+ var loginRequest = new LoginRequest(baseUri, clientId, 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 fragmentParams = uri.Fragment.Substring(maxLen)
+ ?.Split("&", StringSplitOptions.RemoveEmptyEntries)
+ ?.Select(param => param.Split("=", StringSplitOptions.RemoveEmptyEntries))
+ ?.ToDictionary(param => param[0], param => param[1]) ?? new Dictionary();
+
+ _isAuthed = fragmentParams.ContainsKey("access_token");
+ if (_isAuthed)
+ {
+ var spotify = new SpotifyClient(fragmentParams["access_token"]);
+
+ _me = await spotify.UserProfile.Current();
+ _totalPlaylistCount = (await spotify.Playlists.CurrentUsers()).Total;
+ }
+ }
+}
diff --git a/SpotifyAPI.Web.Examples/Example.ASPBlazor/Program.cs b/SpotifyAPI.Web.Examples/Example.ASPBlazor/Program.cs
index 467cb166..3d140592 100644
--- a/SpotifyAPI.Web.Examples/Example.ASPBlazor/Program.cs
+++ b/SpotifyAPI.Web.Examples/Example.ASPBlazor/Program.cs
@@ -1,17 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
-using Microsoft.Extensions.Logging;
namespace Example.ASPBlazor
{
- public class Program
+ public class Program
{
public static void Main(string[] args)
{
diff --git a/SpotifyAPI.Web.Examples/Example.ASPBlazor/Shared/NavMenu.razor b/SpotifyAPI.Web.Examples/Example.ASPBlazor/Shared/NavMenu.razor
index 70bb92be..bd440715 100644
--- a/SpotifyAPI.Web.Examples/Example.ASPBlazor/Shared/NavMenu.razor
+++ b/SpotifyAPI.Web.Examples/Example.ASPBlazor/Shared/NavMenu.razor
@@ -1,4 +1,4 @@
-