问题
I'm making an Android's app using Spotify SDK and Spotify Web Api Android from kaaes. What's the best way to refresh my access token? Since i need to keep the user logged.
I don't want that my app ask for log in everytime the users open the app.
How can I handle this ?
retrofit.RetrofitError: 401 Unauthorized
Login to Spotify failed because of invalid credentials
Thanks for your time and help! Regards.
回答1:
You need to use the Authorization Code flow from the Spotify Web API to obtain a refresh token that you can use to obtain a new access token when yours expires.
For that you need to have a web service with which you communicate from the Android app.
There is more information on this on https://github.com/spotify/android-sdk/issues/47
回答2:
In case anyone else is having trouble with this issue, I made a gist you can use to stand up a free cloud function and handle this process:
https://gist.github.com/rldaulton/8b87216715d3cea828b5a9b27e300a3f
来源:https://stackoverflow.com/questions/30085038/how-to-refresh-access-token-on-spotify-sdk-for-android