Skip to content

Commit d245139

Browse files
committed
Added more example docs
1 parent fdb0400 commit d245139

14 files changed

+106
-9
lines changed

SpotifyAPI.Docs/docs/auth_introduction.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Since every auth flow also needs an application in the [spotify dashboard](https
1212

1313
Then, continue with the docs of the specific auth flows:
1414

15-
* [Client Credentials](client_credentials)
16-
* [Implicit Grant](implicit_grant)
17-
* [Authorization Code](authorization_code)
18-
* Token Swap
15+
* [Client Credentials](client_credentials.md)
16+
* [Implicit Grant](implicit_grant.md)
17+
* [Authorization Code](authorization_code.md)
18+
* [Token Swap](token_swap.md)
1919

2020
![auth comparison](/img/auth_comparison.png)

SpotifyAPI.Docs/docs/configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ public HttpResult Get()
4545
}
4646
```
4747

48-
This way, a single `HTTPClient` will be used. For a real world example, checkout the [ASP.NET Example](example_aspnet)
48+
This way, a single `HTTPClient` will be used. For a real example, checkout the [ASP.NET Example](example_asp.md)

SpotifyAPI.Docs/docs/example_asp.md

+24
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,27 @@
22
id: example_asp
33
title: ASP.NET
44
---
5+
6+
## Description
7+
8+
This example is based on ASP .NET Core. It uses `Authorization Code` under the hood with the help of [`AspNet.Security.OAuth.Spotify`](https://www.nuget.org/packages/AspNet.Security.OAuth.Spotify/). It stores the access token in the current user session (cookie-based) and allows to refresh tokens when they expire. Two pages are implemented:
9+
10+
* Home shows your current playlists via pagination
11+
* Profile shows your current profile information
12+
13+
![ASP Example - Home](/img/asp_example_home.png)
14+
![ASP Example - Profile](/img/asp_example_profile.png)
15+
16+
## Run it
17+
18+
Before running it, make sure you created an app in your [spotify dashboard](https://developer.spotify.com/dashboard/) and `https://localhost:5001` is a redirect uri of it.
19+
20+
```bash
21+
# Assumes linux and current working directory is the cloned repository
22+
cd SpotifyAPI.Web.Examples/Example.ASP
23+
dotnet restore
24+
25+
SPOTIFY_CLIENT_ID=YourClientId SPOTIFY_CLIENT_SECRET=YourClientSecret dotnet run
26+
27+
# Visit https://localhost:5001
28+
```
+21-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
---
22
id: example_blazor
3-
title: ASP.NET Blazor
3+
title: Blazor ServerSide
44
---
5+
6+
## Description
7+
8+
Very similar to the [Blazor WASM Example](example_blazor_wasm.md), but runs code on the server side and pushes view updates to the client.
9+
10+
![ASP Blazor Example - Home](/img/asp_blazor_example_home.png)
11+
12+
## Run it
13+
14+
Before running it, make sure you created an app in your [spotify dashboard](https://developer.spotify.com/dashboard/) and `https://localhost:5001` is a redirect uri of it.
15+
16+
```bash
17+
# Assumes linux and current working directory is the cloned repository
18+
cd SpotifyAPI.Web.Examples/Example.ASPBlazor
19+
dotnet restore
20+
21+
SPOTIFY_CLIENT_ID=YourClientId SPOTIFY_CLIENT_SECRET=YourClientSecret dotnet run
22+
23+
# Visit https://localhost:5001
24+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
id: example_blazor_wasm
3+
title: Blazor WASM
4+
---
5+
6+
## Description
7+
8+
This small cross-platform web app runs on `Blazor WebAssembly`, which was released on 19. May 2020. It allows to run C# code in any browser which supports WebAssembly. This allows to create .NET full-stack web projects without writing any JavaScript. Find more about [Blazor WebAssembly here](https://devblogs.microsoft.com/aspnet/blazor-webassembly-3-2-0-now-available/)
9+
10+
Since this library is compatible with `.NET Standard 2.1`, you can use all features of `SpotifyAPI.Web` in your blazor wasm app. The example logs the user in via `Implicit Grant` and does 2 user-related API requests from the browser. You can observe the requests from your browsers network tools.
11+
12+
![BlazorWASM Spotify Example](/img/blazorwasm_homepage.png)
13+
14+
![BlazorWASM Spotify Example - network tools](/img/blazorwasm_network_tools.png)
15+
16+
## Run it
17+
18+
Before running it, make sure you created an app in your [spotify dashboard](https://developer.spotify.com/dashboard/) and `https://localhost:5001` is a redirect uri of it.
19+
20+
```bash
21+
# Assumes linux and current working directory is the cloned repository
22+
cd SpotifyAPI.Web.Examples/Example.BlazorWASM
23+
dotnet restore
24+
25+
echo "{ \"SPOTIFY_CLIENT_ID\": \"YourSpotifyClientId\" }" > wwwroot/appsettings.json
26+
dotnet run
27+
28+
# Visit https://localhost:5001
29+
```

SpotifyAPI.Docs/docs/getting_started.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Program
5757
```
5858

5959
:::tip
60-
Notice that the spotify api does not allow unauthorized API access. Wondering where you should get an access token from? For a quick test, head over to the [Spotify Developer Console](https://developer.spotify.com/console/get-album/) and generate an access token with the required scopes! For a permanent solution, head over to the [authentication guides](auth_introduction).
60+
Notice that the spotify api does not allow unauthorized API access. Wondering where you should get an access token from? For a quick test, head over to the [Spotify Developer Console](https://developer.spotify.com/console/get-album/) and generate an access token with the required scopes! For a permanent solution, head over to the [authentication guides](auth_introduction.md).
6161

6262
:::
6363

@@ -105,4 +105,4 @@ If a query/body parameter is required, it has to be supplied in the constructor
105105

106106
## Guides
107107

108-
All other relevant topics are covered in the "Guides" and [Authentication Guides](auth_introduction) section in the sidebar!
108+
All other relevant topics are covered in the "Guides" and [Authentication Guides](auth_introduction.md) section in the sidebar!

SpotifyAPI.Docs/docs/token_swap.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Token Swap
55

66
Token Swap provides an authenticatiow flow where client-side apps (like cli/desktop/mobile apps) are still able to use long-living tokens and the oppurtunity to refresh them without exposing your application's secret. This however requires a server-side part to work.
77

8-
It is based on the [Authorization Code](authorization_code) flow and is also documented by spotify: [Token Swap and Refresh ](https://developer.spotify.com/documentation/ios/guides/token-swap-and-refresh/).
8+
It is based on the [Authorization Code](authorization_code.md) flow and is also documented by spotify: [Token Swap and Refresh ](https://developer.spotify.com/documentation/ios/guides/token-swap-and-refresh/).
99

1010
## Flow
1111

SpotifyAPI.Docs/sidebars.js

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module.exports = {
3333
label: 'Examples',
3434
items: [
3535
'example_asp',
36+
'example_blazor_wasm',
3637
'example_blazor',
3738
'example_cli_custom_html',
3839
'example_cli_persistent_config',
Loading
Loading
Loading
Loading
Loading

SpotifyAPI.sln

+23
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Example.TokenSwap", "Exampl
3030
EndProject
3131
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "SpotifyAPI.Web.Examples\Example.TokenSwap\Client\Client.csproj", "{D5C85F68-BE15-4CF3-A84B-98EEBCA584AD}"
3232
EndProject
33+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example.BlazorWASM", "SpotifyAPI.Web.Examples\Example.BlazorWASM\Example.BlazorWASM.csproj", "{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}"
34+
EndProject
3335
Global
3436
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3537
Debug|Any CPU = Debug|Any CPU
@@ -230,6 +232,26 @@ Global
230232
{D5C85F68-BE15-4CF3-A84B-98EEBCA584AD}.Release|x64.Build.0 = Release|Any CPU
231233
{D5C85F68-BE15-4CF3-A84B-98EEBCA584AD}.Release|x86.ActiveCfg = Release|Any CPU
232234
{D5C85F68-BE15-4CF3-A84B-98EEBCA584AD}.Release|x86.Build.0 = Release|Any CPU
235+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
236+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
237+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Debug|ARM.ActiveCfg = Debug|Any CPU
238+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Debug|ARM.Build.0 = Debug|Any CPU
239+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Debug|ARM64.ActiveCfg = Debug|Any CPU
240+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Debug|ARM64.Build.0 = Debug|Any CPU
241+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Debug|x64.ActiveCfg = Debug|Any CPU
242+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Debug|x64.Build.0 = Debug|Any CPU
243+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Debug|x86.ActiveCfg = Debug|Any CPU
244+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Debug|x86.Build.0 = Debug|Any CPU
245+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
246+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Release|Any CPU.Build.0 = Release|Any CPU
247+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Release|ARM.ActiveCfg = Release|Any CPU
248+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Release|ARM.Build.0 = Release|Any CPU
249+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Release|ARM64.ActiveCfg = Release|Any CPU
250+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Release|ARM64.Build.0 = Release|Any CPU
251+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Release|x64.ActiveCfg = Release|Any CPU
252+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Release|x64.Build.0 = Release|Any CPU
253+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Release|x86.ActiveCfg = Release|Any CPU
254+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2}.Release|x86.Build.0 = Release|Any CPU
233255
EndGlobalSection
234256
GlobalSection(SolutionProperties) = preSolution
235257
HideSolutionNode = FALSE
@@ -242,6 +264,7 @@ Global
242264
{258D1593-5B3B-485F-A71F-54D7FAB221FA} = {48A7DE65-29BB-409C-AC45-77F6586C0B15}
243265
{A2A74C61-9AEE-4802-9E29-518CB8053E6F} = {48A7DE65-29BB-409C-AC45-77F6586C0B15}
244266
{D5C85F68-BE15-4CF3-A84B-98EEBCA584AD} = {A2A74C61-9AEE-4802-9E29-518CB8053E6F}
267+
{D6E9A2B1-3219-4AF3-87E5-D2E7AB3063A2} = {48A7DE65-29BB-409C-AC45-77F6586C0B15}
245268
EndGlobalSection
246269
GlobalSection(ExtensibilityGlobals) = postSolution
247270
SolutionGuid = {097062B8-0E87-43C8-BD98-61843A68BE6D}

0 commit comments

Comments
 (0)