spotify api axios react post 请求 403 错误
spotify api axios react post request 403 error
makePlaylist = event => {
event.preventDefault()
let token = localStorage.getItem('token')
let playlist = {name: this.state.text, public:false}
axios.post(
`https://api.spotify.com/v1/users/${this.state.user_id}/playlists`, playlist,
{headers: {
"Authorization": 'Bearer ' + token
}
}
)
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
})
}
我收到以下错误
https://api.spotify.com/v1/users/my_user_id_here/playlists 403 error
我在
上在线查找了文档
https://developer.spotify.com/documentation/web-api/reference/playlists/create-playlist/
据我所知,我似乎正在设置。有人知道我在请求中做错了什么吗?我知道访问令牌有效。
"Trying to create a playlist when you do not have the user’s authorization returns error 403 Forbidden." 确保您在 Dashboard 中制作的 Spotify 应用对您尝试为其创建播放列表的用户具有适当的范围权限。
这是创建私人播放列表的范围:https://developer.spotify.com/documentation/general/guides/scopes/#playlist-modify-private
以下是通过传入范围设置授权的教程:
https://developer.spotify.com/documentation/general/guides/authorization-guide/
makePlaylist = event => {
event.preventDefault()
let token = localStorage.getItem('token')
let playlist = {name: this.state.text, public:false}
axios.post(
`https://api.spotify.com/v1/users/${this.state.user_id}/playlists`, playlist,
{headers: {
"Authorization": 'Bearer ' + token
}
}
)
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
})
}
我收到以下错误
https://api.spotify.com/v1/users/my_user_id_here/playlists 403 error
我在
上在线查找了文档https://developer.spotify.com/documentation/web-api/reference/playlists/create-playlist/
据我所知,我似乎正在设置。有人知道我在请求中做错了什么吗?我知道访问令牌有效。
"Trying to create a playlist when you do not have the user’s authorization returns error 403 Forbidden." 确保您在 Dashboard 中制作的 Spotify 应用对您尝试为其创建播放列表的用户具有适当的范围权限。
这是创建私人播放列表的范围:https://developer.spotify.com/documentation/general/guides/scopes/#playlist-modify-private
以下是通过传入范围设置授权的教程:
https://developer.spotify.com/documentation/general/guides/authorization-guide/