How to refresh Access Token on Spotify SDK for Android?

匆匆过客 提交于 2019-12-21 13:05:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!