从Spotify访问令牌

时间:2018-06-26 02:13:12

标签: node.js api request spotify

Process from spotify on how to retrieve access token

我正在尝试从Spotify的api中检索和访问令牌。我的请求代码如下,其描述为上图。错误状态为415,并说它是意外错误,有人可以告诉我我做错了什么。谢谢!

    const options = {
      method: "POST",
      uri: "https://accounts.spotify.com/api/token",
      formData: {
        grant_type: "authorization_code",
        code: `${req.query.code}`,
        redirect_uri: "http://localhost:3000/test",
        client_id: keys.spotify.client_id,
        client_secret: keys.spotify.client_secret,
      },
      headers: {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };

    request(options).then(response => {
      res.send(response.response)
    }).catch(err => {
      res.json({err})
    })

0 个答案:

没有答案
相关问题