2

xinranxiao:spotify-web-apiMeteorJSのプレイリストからトラックにアクセスしようとしています。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

データを表示してアクセスすることはできますが、トラックの href URL を指定すると 401 エラーが発生しますか?

4

0 に答える 0