更新时间:2023-01-29 18:38:39
Spotify API playlists
endpoint requires authentication token.
非常原始的示例,在这些行中,您可以获得Auth Token
:
Very primitive example, in those lines you can get Auth Token
:
// use the access token to access the Spotify Web API
request.get(options, function(error, response, body) {
console.log(body);
token = access_token;
});
然后,获取播放列表的代码:
Then, your code for getting playlists:
var token = '';
app.get('/playlists', function(req, res) {
var state = generateRandomString(16);
res.cookie(stateKey, state);
// your application requests authorization
var scope = 'playlist-read-private';
res.redirect('https://api.spotify.com/v1/me/playlists?' +
querystring.stringify({
access_token: token,
token_type: 'Bearer',
response_type: 'code',
client_id: client_id,
scope: scope,
redirect_uri: redirect_uri,
state: state
}));
});
首先,您访问' http://localhost:8888/login `进行身份验证,然后,您转到播放列表的" http://localhost:8888/playlists ".
First, you visiting 'http://localhost:8888/login` for authentification, then, you going to 'http://localhost:8888/playlists' for playlists.