【问题标题】:In Google Scripts: UrlFetchApp.fetch(''https://accounts.spotify.com/api/token'') returns code 405在 Google 脚本中: UrlFetchApp.fetch(''https://accounts.spotify.com/api/token'') 返回代码 405
【发布时间】:2017-11-19 16:46:30
【问题描述】:

在 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

【问题讨论】:

    标签: javascript spotify libspotify


    【解决方案1】:

    您的请求格式不正确。如果您仔细查看 the documentation,您会发现只有 grant_type 应该作为请求正文参数发送。

    客户端 ID 和机密应作为标头参数发送。参数名称应为Authorization,参数值应为Basic [base_64_encoded_value_of(client_id:client_secret)]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-30
      • 2017-09-27
      • 2023-03-30
      • 2016-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-15
      相关资源
      最近更新 更多