无法从 Spotify API 获取访问令牌

Can't get access token from Spotify API

我正在尝试使用请求模块向 https://accounts.spotify.com/api/token 发出 POST 请求以获得访问令牌。我已经使用我的 Spotify 开发帐户注册了重定向 URI。这是我的快递 /redirect 路线。

const Request = require('request');

module.exports = (req, res) => {
  const data = {
    grant_type: 'authorization_code',
    code: req.query.code,
    redirect_uri: 'http://localhost:3000/redirect',
    client_id: process.env.SPOTIFY_ID,
    client_secret: process.env.SPOTIFY_SECRET
  }

  const options = {
    method: 'POST',
    url: 'https://accounts.spotify.com/api/token',
    json: true,
    body: data
  }

  Request(options, (error, response, body) => {
    if (error) return console.log(error);
    res.end(body);
  });
};

谁能看出这里可能出了什么问题?我每次得到的都是一个不起眼的 'Oops! Something went wrong' 错误页面。

数据参数必须作为表单数据传递:

const options = {
  method: 'POST',
  url: 'https://accounts.spotify.com/api/token',
  json: true,
  form: data
}