首页 > 解决方案 > 在交换访问令牌的代码时获取“grant_type 参数丢失”,Spotify API PKCE 流

问题描述

我正在尝试实现 PKCE 流程。在第一步中,我生成了代码验证器和质询并请求了代码。现在我应该用代码交换访问令牌。有关流程的更多信息:https ://developer.spotify.com/documentation/general/guides/authorization-guide/#authorization-code-flow-with-proof-key-for-code-exchange-pkce

axios({
  method: "POST",
  url: "https://accounts.spotify.com/api/token",
  headers: {
    "Content-Type": "application/x-www-form-urlencoded",
  },
  params: qs.stringify({
    client_id: client_id,
    grant_type: "authorization_code",
    code: responseCode,
    redirect_uri: "http://localhost:3000/",
    code_verifier: verifier
  })
}).then(function (response) {
  console.log(response);
}).catch(function (err) {
  console.log(err);
})

标签: javascriptapiaxiosspotify

解决方案


推荐阅读