在Google脚本中,我尝试从spotify调用client_credentials OAuth流,而它应该返回访问令牌,请求失败,代码为405.
data = {
'grant_type':'client_credentials',
'client_id' : 'CLIENT_ID',
'client_secret' : 'CLIENT_SECRET'
}
var access_token= UrlFetchApp.fetch('https://accounts.spotify.com/api/token', data);
更多关于spotify OAUTH的信息 https://developer.spotify.com/web-api/authorization-guide/#client-credentials-flow
答案 0 :(得分:0)
您的请求未正确格式化。如果您仔细查看the documentation,您会发现只有 grant_type 应作为请求正文参数发送。
客户端ID和密钥应作为标头参数发送。参数名称应为授权,参数值应为 Basic [base_64_encoded_value_of(client_id:client_secret)]