question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What versions of the api are still working for AuthorizationCodeAuth method

See original GitHub issue

Hey there,

Just checking out if older version are still working/supported with AuthorizationCodeAuth method ? I’m using 4.0.0 .Web and .Web.Auth It used to work a long time without touching the class and now it stopped working, the api is not able to retrieve to current song, always null. But the step before still works, I’m still able to authorize the app on my spotify-dev account and get you can close this page now

public SpotifyAPI(string clientId, string secretId, string redirectUrl = "http://localhost:4002")
{
    _clientId = clientId;
    _secretId = secretId;

    if (!string.IsNullOrEmpty(_clientId) && !string.IsNullOrEmpty(_secretId))
    {
        var auth = new AuthorizationCodeAuth(_clientId, _secretId, redirectUrl, redirectUrl,
            Scope.Streaming | Scope.PlaylistReadCollaborative | Scope.UserReadCurrentlyPlaying | Scope.UserReadRecentlyPlayed | Scope.UserReadPlaybackState);
        auth.AuthReceived += AuthOnAuthReceived;
        auth.Start();
        auth.OpenBrowser();
    }
}
private async void AuthOnAuthReceived(object sender, AuthorizationCode payload)
{
    _authorizationCodeAuth = (AuthorizationCodeAuth)sender;
    _authorizationCodeAuth.Stop();

    _token = await _authorizationCodeAuth.ExchangeCode(payload.Code);

    // remember when to renew the 60 minutes token (10 minutes upfront)
    _nextTokenRenewal = DateTimeOffset.UtcNow.AddSeconds(_token.ExpiresIn).AddMinutes(-10);
}
private async Task<SpotifyWebAPI> GetSpotifyWebAPI()
{
    if (_token == null) return null;

    if (DateTimeOffset.UtcNow >= _nextTokenRenewal)
    {
        _token = await _authorizationCodeAuth.RefreshToken(_token.RefreshToken);
    }

    return new SpotifyWebAPI
    {
        AccessToken = _token.AccessToken,
        TokenType = _token.TokenType
    };
}

and I use it this way , Item, is always null while playing a track. On spotify-dev website, my app redirectURI is http://localhost:4002

var api = await GetSpotifyWebAPI();

if (api == null) return false;

var playback = await api.GetPlaybackAsync();

if (playback.HasError() || playback.Item == null)
{
    // item always null
}

SpotifyAPI was the reason I needed to upgrade to recent .NET framework and removed support on Vista. Since 4.2.0 is on .NET Standard 2.0, I don’t need to offer support on other platforms or ask user to install more .NET packages to support the SpotifyAPI. I will prefer to remove it at this point and work without it.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
JohnnyCrazycommented, Jan 12, 2020

Yea 90% sure it’s that. If nothing is played, an empty object is sent by the API. Thus, the object has default values.

img

0reactions
JohnnyCrazycommented, Jan 12, 2020

Yea, super cool that lidarr and even the botframework uses it.

I’m not sure why they shut it down since they didn’t communicate it at all. But I think the local API was a hassle to maintain and buggy as hell, so this could also be the reason for the shutdown.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OAuth 2.0
OAuth 2.0 is the industry-standard protocol for authorization. OAuth 2.0 focuses on client developer simplicity while providing specific authorization flows ...
Read more >
Using OAuth 2.0 to Access Google APIs | Authorization
Google APIs use the OAuth 2.0 protocol for authentication and authorization. Google supports common OAuth 2.0 scenarios such as those for web server,...
Read more >
Which OAuth 2.0 Flow Should I Use?
The OAuth 2.0 Authorization Framework supports several different flows (or grants). ... API for implementing Authorization Code Flow with PKCE in SPAs.
Read more >
Using OAuth 2.0 for Web Server Applications | Authorization
OAuth 2.0 allows users to share specific data with an application while keeping their usernames, passwords, and other information private.
Read more >
Authorization Code Flow
The Authorization Code Flow (defined in OAuth 2.0 RFC 6749, section 4.1), involves exchanging an authorization code for a token.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found