//Authenticate the program public async Task Authenticate() { //The server side php code came from here: https://github.com/rollersteaam/spotify-token-swap-php webApiFactory = new TokenSwapWebAPIFactory("http://mrhumagames.com/MrhumasMusicOverlay/index.php") { Scope = Scope.UserReadCurrentlyPlaying, AutoRefresh = true, HostServerUri = "http://localhost:4002/auth", Timeout = 30 }; //If the user denied the request webApiFactory.OnAuthFailure += (sender, e) => { //Let the user know they must accept in order to use the program with Spotify MessageBox.Show("You must accept the authentication request in order to use this program with Spotify."); authorized = false; }; //If the user accepted the request webApiFactory.OnAuthSuccess += (sender, e) => { authorized = true; }; try { api = await webApiFactory.GetWebApiAsync(); } catch (Exception ex) { MessageBox.Show("Spotify failed to load: " + ex.Message); } }
public SpotifyService() { webApiFactory = new TokenSwapWebAPIFactory("/") { Scope = Scope.UserReadPrivate | Scope.UserReadEmail | Scope.PlaylistReadPrivate, AutoRefresh = true }; }