Skip to content

Commit d245139

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

14 files changed

Lines changed: 106 additions & 9 deletions

‎SpotifyAPI.Docs/docs/auth_introduction.md‎

Lines changed: 4 additions & 4 deletions
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‎

Lines changed: 1 addition & 1 deletion
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‎

Lines changed: 24 additions & 0 deletions
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+
```
Lines changed: 21 additions & 1 deletion
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+
```
Lines changed: 29 additions & 0 deletions
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‎

Lines changed: 2 additions & 2 deletions
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‎

Lines changed: 1 addition & 1 deletion
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‎

Lines changed: 1 addition & 0 deletions
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',
23.6 KB
Loading
129 KB
Loading

0 commit comments

Comments
 (0)