[英](Spotify Web API) Create New Playlist - POST request returning 'Error 403 (Forbidden)'
Here is the link to the Web API notes on how to create a new playlist. 以下是有关如何创建新播放列表的Web API说明的链接。 https://developer.spotify.com/web-api/create-playlist/
https://developer.spotify.com/web-api/create-playlist/
As far as I understand, the POST requests the url https://api.spotify.com/v1/users/{user_id}/playlists
. 据我了解,POST请求网址
https://api.spotify.com/v1/users/{user_id}/playlists
。 This is requested while passing the access token and data. 在传递访问令牌和数据时请求此操作。 The content type of the data being 'application/json'.
数据的内容类型是'application / json'。
For some reason this is failing and returning a Error 403 (Forbidden) in the console. 由于某种原因,这是失败的,并在控制台中返回错误403(禁止) 。
Anything I'm missing? 我缺少什么?
//(playlistName, userId, accessToken) are passed to this. var urlString = 'https://api.spotify.com/v1/users/' + userId + '/playlists'; var jsonData = { "name": playlistName, "public": false }; $.ajax({ type: 'POST', url: urlString, data: jsonData, dataType: 'json', headers: { 'Authorization': 'Bearer ' + accessToken }, contentType: 'application/json', success: function(result) { console.log('Woo! :)'); }, error: function() { console.log('Error! :('); } })
Having tried your example, I get a 401 unauthorized
when filling in bogus data. 在尝试了你的例子后,我在填写虚假数据时获得了
401 unauthorized
。 So you are authorized, but the API really does not grant you the rights ( 403 forbidden
). 所以你被授权,但API真的不授予你权利(
403 forbidden
)。
Please have a look at the authorization guide. 请查看授权指南。 I am pretty sure, your error is there.
我很确定,你的错误就在那里。 Especially have a look at
scope
. 特别是看看
scope
。 You might simply not grant enough power in the login. 您可能根本没有在登录中授予足够的权力。 And therefore ending up with only public access, which does not include adding playlists.
因此最终只有公共访问,不包括添加播放列表。
I cite form the API docs: 我引用了API文档:
To be able to create private playlists, the user must have granted the
playlist-modify-private
scope.为了能够创建私人播放列表,用户必须已授予
playlist-modify-private
范围。
https://developer.spotify.com/web-api/authorization-guide/ https://developer.spotify.com/web-api/authorization-guide/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.