bih / spotify-token-swap-service

Swap tokens for using Spotify APIs and SDKs, made really simple 🔑 ⛓
MIT License
41 stars 26 forks source link

Refresh Tokens #3

Closed lewisking closed 5 years ago

lewisking commented 5 years ago

Hey,

I'm having issues with refresh tokens. I'm sending the following to a heroku instance:

let refreshToken = `https://poolsidelive.herokuapp.com/api/refresh_token?refresh_token=Hqomr5nlHgJNTTi7CIaOWUU6kHfm6bGO1Td+vWJqmkdYrMVg5IxyAJBdckHJ%0AIcFNOUAzPnxxwRf/PiP8P5HpPyrnWK0WhuE5SjnXjEieadwOajtyXygsfHH2%0AcLe0AkWEsQh9HUqxVruR4bmw/hcXa4CA1RxnhyFStUwLszw594VfBfcrPy8x%0AGA==%0A`

API.post(refreshToken).then((response) => {
  console.log("Updating access tokens", response);
});

Which returns the following:

"error: "invalid refresh_token".

Everything else I do works correctly (getting access tokens, authoring with Spotify. The only thing I can see with the error is “OpenSSL::Cipher::CipherError” is triggering the error I'm seeing. I'm not sure why I am getting that!

Any help would be greatly appreciated.

bih commented 5 years ago

The issue is that you need to URL encode your refresh_token. That'll fix your problem. Also I've added a patch that'll remove the OpenSSL::Cipher::CipherError issue (which is related to a dependency). You'll need to update your code with the latest changes to master in this GitHub repository.

Hope this helps! :)