1
Vote

Bug: Refreshing Authentication Token not possible

description

The Authentication.GetAccessToken() method, used in AuthenticationToken.Refresh() has to be slightly altered or replaced with another one, because if refreshed, the Spotify Web API expects the RefreshToken to be stored in a post parameter named refresh_token, not code.

Also, the grant_type has to be changed to "refresh_token" in this scenario.

Proposal
        public async static Task<AuthenticationToken> GetAccessToken(string code)
        {
            Dictionary<string, string> postData = new Dictionary<string, string>();
            postData.Add("grant_type", "authorization_code");
            postData.Add("code", code);
            ....
        }
        // Overload existing method with second use case
        public async static Task<AuthenticationToken> GetAccessToken(AuthenticationToken authToken)
        {
            Dictionary<string, string> postData = new Dictionary<string, string>();
            postData.Add("grant_type", "refresh_token");
            postData.Add("refresh_token", authToken.RefreshToken);
            ....
        }
        // OR add a completely new one?
        public async static Task<AuthenticationToken> RefreshAccessToken(string refreshToken)
        {
            Dictionary<string, string> postData = new Dictionary<string, string>();
            postData.Add("grant_type", "refresh_token");
            postData.Add("refresh_token", refreshToken);
            ....
        }
Hope you can fix this bug, because my application really depends on the ability to refresh the access token.

comments

wrote Apr 16, 2015 at 1:44 PM

wrote Apr 16, 2015 at 2:59 PM

tinyioda wrote Apr 18, 2015 at 1:46 AM

Hi makhani,

Thanks for supporting my project. I really appreciate it!

I am swamped this week with some huge deadlines but if you can give me 2 weeks or so, I'll do my best!

That said the code is there for the taking. If you figure out the issue I'll be sure to incorporate your fix into the solution with full credit given!

makhani wrote Apr 18, 2015 at 3:54 PM

Hey!

No problem, don't stress yourself.

I would like to do it myself, but I'm used to Bitbucket/Github, I just registered at Codeplex. I don't know yet how to fork something or make a pull request in CodePlex. As soon as I figure it out, I'll fix it myself! :)