From 18863f17339311b6a0942f0f3bdaac41f5633890 Mon Sep 17 00:00:00 2001 From: Jonas Dellinger Date: Sat, 22 Dec 2018 21:15:29 +0100 Subject: [PATCH] Fix example --- SpotifyAPI.Web.Example/Program.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/SpotifyAPI.Web.Example/Program.cs b/SpotifyAPI.Web.Example/Program.cs index 4e05d574..13e6eb59 100644 --- a/SpotifyAPI.Web.Example/Program.cs +++ b/SpotifyAPI.Web.Example/Program.cs @@ -24,11 +24,19 @@ namespace SpotifyAPI.Web.Example Console.WriteLine("This example uses AuthorizationCodeAuth."); Console.WriteLine( "Tip: If you want to supply your ClientID and SecretId beforehand, use env variables (SPOTIFY_CLIENT_ID and SPOTIFY_SECRET_ID)"); - - CredentialsAuth auth = new CredentialsAuth(_clientId, _secretId); - Token token = await auth.GetToken(); - SpotifyWebAPI api = new SpotifyWebAPI() { TokenType = token.TokenType, AccessToken = token.AccessToken}; - + + AuthorizationCodeAuth auth = + new AuthorizationCodeAuth(_clientId, _secretId, "http://localhost:4002", "http://localhost:4002", + Scope.PlaylistReadPrivate | Scope.PlaylistReadCollaborative); + auth.AuthReceived += async (sender, payload) => + { + auth.Stop(); + Token token = await auth.ExchangeCode(payload.Code); + SpotifyWebAPI api = new SpotifyWebAPI() {TokenType = token.TokenType, AccessToken = token.AccessToken}; + }; + auth.Start(); + auth.OpenBrowser(); + Console.ReadLine(); auth.Stop(0); }