Skip to content

Fix: Encrypted refresh tokens containing '+' were being incorrectly encoded#70

Closed
Mohamad-Kredly wants to merge 0 commit intoPeter-Schorn:masterfrom
Technofossils:master
Closed

Fix: Encrypted refresh tokens containing '+' were being incorrectly encoded#70
Mohamad-Kredly wants to merge 0 commit intoPeter-Schorn:masterfrom
Technofossils:master

Conversation

@Mohamad-Kredly
Copy link
Copy Markdown

Fixed an issue where an encrypted refresh token containing the '+' symbol would be sent as a space instead, failing the refresh.

Context:

I was using the SpotifySDK to auth based off of the example project and I was having problems where sometimes the token fails to refresh when using the AuthorizationCodeFlowBackend's refresh. Refreshing with the SessionManager didn't have any issues so I looked at the backend and I saw that the token sent from SpotifyAPI was being decoded as a space instead of the +.

The backend used is the one in the SpotifySDK demo projects:
https://github.com/spotify/ios-sdk/blob/master/DemoProjects/spotify_token_swap.rb

I'm unsure if this occurs on other servers and if this is instead a fault from the backend I'm using 😅

@Peter-Schorn
Copy link
Copy Markdown
Owner

Hi Mohamad,

Thanks for bringing this issue to my attention. You are, indeed, correct that Dictionary.formURLEncoded() is not properly percent-encoding the + character. After further investigation, I determined that there may be other characters that may not be encoded correctly. I have made my own changes to the Dictionary.formURLEncoded() method and will release a new version shortly.

@Peter-Schorn
Copy link
Copy Markdown
Owner

Just pushed version 4.0.1, which should fix this issue by properly percent-encoding the + character, among other characters. Please confirm it is working for you and I will close this PR.

@Mohamad-Kredly
Copy link
Copy Markdown
Author

Just got around to testing your fix and it works, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants