SpotifyAPI-NET icon indicating copy to clipboard operation
SpotifyAPI-NET copied to clipboard

AutorizationCodeAuth causes "savehandle has been closed" exception

Open Gruhlum opened this issue 9 years ago • 1 comments

the following code taken from the spotifyWebApi documentation has a ~20% chance to crash

private static void auth_OnResponseReceivedEvent(AutorizationCodeAuthResponse response)
{
    //Stop the HTTP Server, done.
    auth.StopHttpServer();

    //NEVER DO THIS! You would need to provide the ClientSecret.
    //You would need to do it e.g via a PHP-Script.
    Token token = auth.ExchangeAuthCode(response.Code, "XXXXXXXXXXX");

    var spotify = new SpotifyWebApiClass()
    {
        TokenType = token.TokenType,
        AccessToken = token.AccessToken
    };

    //With the token object, you can now make API calls
}

Putting the line auth.StopHttpServer(); at the end of the function fixes the problem.

Gruhlum avatar Sep 30 '17 15:09 Gruhlum

Reordered docs in dcf4eefc619470e6b28a159ab27a021eaa47d981

The internal HTTP-Server is still very unstable and needs a new implementation, so don't expect too much.

JohnnyCrazy avatar Sep 30 '17 21:09 JohnnyCrazy