1

I've pulled a client_credentials token and while I can access other parts of the API, I can't seem to pull playlist information. It's definitely a public playlist, yet I'm getting 401 Unauthorized. Am I just misunderstanding something?

Edit For example, this works: puts curl -I -s -X GET "https://api.spotify.com/v1/users/#{testUser}" -H "Authorization: Bearer {#{@accessToken}}"

This does not: puts curl -I -s -X GET "https://api.spotify.com/v1/users/#{testUser}/playlists/#{testPlaylist}?fields=href,name,owner(!href,external_urls),tracks.items(added_by.id,track(name,href,album(name,href)))" -H "Authorization: Bearer {#{@accessToken}}"

Max
  • 597
  • 7
  • 21
  • What's the error message? – Michael Thelin Nov 08 '16 at 12:47
  • "This request requires authentication". Not getting any more than that unfortunately. – Max Nov 08 '16 at 18:26
  • For example... `curl -s -X POST "#{TOKEN_URI}" --data "grant_type=client_credentials" -H "Authorization: Basic #{authorization}"` `curl -I -s -X GET "https://api.spotify.com/v1/users/spotify/playlists/59ZbFPES4DQwEjBpWHzrtC" -H "Authorization: Bearer {#{token}}"` – Max Nov 08 '16 at 18:37

1 Answers1

1

Are you sure you are sending the credentials cookie as part of your request? If you're not sure, you can use Wireshark or a similar tool to see the details of your request.

Edit: Relevant doc, but you've probably already seen this:

https://developer.spotify.com/web-api/get-playlist/

Tim
  • 66
  • 4
  • I'm sending the token, if that's what you mean. For example, this works: puts `curl -I -s -X GET "https://api.spotify.com/v1/users/#{testUser}" -H "Authorization: Bearer {#{@accessToken}}"` This does not: puts `curl -I -s -X GET "https://api.spotify.com/v1/users/#{testUser}/playlists/#{testPlaylist}?fields=href,name,owner(!href,external_urls),tracks.items(added_by.id,track(name,href,album(name,href)))" -H "Authorization: Bearer {#{@accessToken}}"` – Max Nov 07 '16 at 19:33
  • Well, looking at the Spotify doc, that all looks correct to me, so long as you're using the playlist's ID (eg. 59ZbFPES4DQwEjBpWHzrtC), not its name. I assume you've already tried other playlists. Sorry I can't be of more help. – Tim Nov 07 '16 at 19:49
  • Yeah. Weird. The only thing I can think of is if client_credentials isn't the proper token. However, I'm looking at the rspotify gem (which *does* work), and it seems to use client_credentials... so... yeah. Ah. Thanks anyway! – Max Nov 07 '16 at 21:10