Spotify API automated initial authorization

I'm making a personal smart mirror and i'm looking to integrate the spotify API to display my 'currently playing' track. However, I've noticed that in the authorization process, you need to physically click log in and authorize the app in order to get the credentials required to move forward in obtaining your data. Could this be automated/require no user interaction?

I am referring to step 1 of the api authorization guide.

Many thanks.


If you are using this for a personal smart mirror you shouldn't have a problem. You only need to authorize by clicking a button in a browser one time and will be able to make all API calls afterward without needing to click anything.

Specifically, after you do in step 3 of the authorization flow you will be given a refresh token. After the authorization token expires you can use the refresh token to refresh the authorization automatically without clicking anything.

From their documentation:

Accessing your data without showing a login form

I want to interact with the web API and show some data on my website. I see that the endpoints I need authorization, but I don't need/want a login window to pop-up, because I want to grant my own app access to my own playlists once. Is there any way of doing this?

You basically need an access token and a refresh token issued for your user account. For obtaining a pair of access token / refresh token you need to follow the Authorization Code Flow (if you need a certain scope to be approved) or Client Credentials (if you just need to sign your request, like when fetching a certain playlist). Once you obtain them, you can use your access token and refresh it when it expires without having to show any login form.

If its not for you personally you could jump through hoops and write code that fakes being a web browser, perhaps using something like curl or selenium but odds are it is against their terms of service and are if you get caught they'll ban you.

链接地址: http://www.djcxy.com/p/55678.html

上一篇: 使用节点

下一篇: Spotify API自动初始授权