Skip to content

Commit 18863f1

Browse files
author
Jonas Dellinger
committed
Fix example
1 parent 3b7fc1a commit 18863f1

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

‎SpotifyAPI.Web.Example/Program.cs‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,19 @@ static void Main(string[] args)
2424
Console.WriteLine("This example uses AuthorizationCodeAuth.");
2525
Console.WriteLine(
2626
"Tip: If you want to supply your ClientID and SecretId beforehand, use env variables (SPOTIFY_CLIENT_ID and SPOTIFY_SECRET_ID)");
27-
28-
CredentialsAuth auth = new CredentialsAuth(_clientId, _secretId);
29-
Token token = await auth.GetToken();
30-
SpotifyWebAPI api = new SpotifyWebAPI() { TokenType = token.TokenType, AccessToken = token.AccessToken};
31-
27+
28+
AuthorizationCodeAuth auth =
29+
new AuthorizationCodeAuth(_clientId, _secretId, "http://localhost:4002", "http://localhost:4002",
30+
Scope.PlaylistReadPrivate | Scope.PlaylistReadCollaborative);
31+
auth.AuthReceived += async (sender, payload) =>
32+
{
33+
auth.Stop();
34+
Token token = await auth.ExchangeCode(payload.Code);
35+
SpotifyWebAPI api = new SpotifyWebAPI() {TokenType = token.TokenType, AccessToken = token.AccessToken};
36+
};
37+
auth.Start();
38+
auth.OpenBrowser();
39+
3240
Console.ReadLine();
3341
auth.Stop(0);
3442
}

0 commit comments

Comments
 (0)