【发布时间】:2022-12-22 07:04:54
【问题描述】:
将 Spotify 文档用于客户端凭证流 (https://developer.spotify.com/documentation/general/guides/authorization/client-credentials/)
我能够在 javascript 中创建 API 请求:
function getoAuth () {
const client_id = id;
const client_secret = secret;
fetch("https://accounts.spotify.com/api/token", {
method: 'POST',
headers: {
'Content-type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic' + (client_id + ":" + client_secret).toString('base64')
},
form: {
grant_type: 'client_credentials',
},
json: true
})
}
但我收到以下错误:{"error":"unsupported_grant_type","error_description":"grant_type parameter is missing"}
为什么会失败?
【问题讨论】:
标签: javascript node.js api fetch spotify-app