2

我正在尝试使用xinranxiao:spotify-web-apifor MeteorJS 从播放列表中访问曲目。我使用 spotify 帐户登录,并且能够从 spotify api 访问数据。我能够获取用户的播放列表、曲目和艺术家等。但是,如果我尝试使用直接的 href url 播放歌曲,我会得到一个 ``

{
  "error": {
    "status": 401,
    "message": "This request requires authentication."
  }
}

我已经在位于服务器的 js 文件中配置了我的 Spotify:``ServiceConfiguration.configurations.update

(
  { "service": "spotify" },
  {
    $set: {
      "clientId": "eeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "secret": "bbbbbbbbbbbbbbbbbbbbbbb"
    }
  },
  { upsert: true }
);

在我的客户端 js 文件中,我访问了成功运行的播放列表。

getUserPlaylists: function() {
// Get a user's playlists

let spotifyApi = new SpotifyWebApi()

let userplaylists = spotifyApi.getUserPlaylists(Meteor.user().profile.id,function(err,data){
  if(err){
    console.log("Retrieval error ", err)
  }
  else{
    console.log("Success, your playlist ", data.body)
  }
})
return userplaylists
}//end getUserPlaylists

因此,尽管我可以查看和访问数据,但我无法在没有 401 错误的情况下指向 track href url?

4

0 回答 0