9

Soundclouds API is returning 403 on some tracks for me. I have tried playing with the raw http endpoints and also the soundcloud api wrapper for python, both have the issue.

https://api.soundcloud.com/tracks/251164884.json?client_id=CLIENT_ID

The above one returns a 403 error while below one works, using same CLIENT_ID obviously

https://api.soundcloud.com/tracks/197355235.json?client_id=CLIENT_ID

Using the library wrapper I get. requests.exceptions.HTTPError: 403 Client Error: Forbidden

    import soundcloud
    client = soundcloud.Client(client_id=CLIENT_ID)
    track = client.get('/resolve', url='https://soundcloud.com/mtarecords/my-nu-leng-flava-d-soul-shake') 

https://soundcloud.com/calyxteebee/nothing-left Another track that also doesn't resolve. Not all tracks have this issue, most work how they always have.

If you go to the Share -> Embed on Soundcloud the track_id will be in there, so I know I am using the correct track_id.

Viewing the http endpoints in browser I get the error.

Failed to load resource: the server responded with a status of 401 (Unauthorized) - https://api.soundcloud.com/favicon.ico

Anyone else run into this issue before?

Andrew
  • 203
  • 2
  • 10
  • Maybe related to this item? http://stackoverflow.com/questions/35877369/http-requests-to-tracks-id-a-403-status-code-from-aws-other-cloud-providers I'm also still having this problem – PaulDart Mar 14 '16 at 07:06
  • 1
    Are you only getting the error on some tracks or on all tracks? I ran into that other issue when searching around, seems to be describing similar behavior. I would think if the issue is that widespread it would have trigged some failed tests or something on soundclouds end. I guess we just have to play the waiting game? – Andrew Mar 15 '16 at 03:41

3 Answers3

3

Using your two examples I get valid results for both

Example 1:

https://api.soundcloud.com/resolve?url=https://soundcloud.com/calyxteebee/nothing-left&client_id=CLIENT_ID

returns

https://api.soundcloud.com/tracks/251164884?client_id=CLIENT_ID

Example 2:

https://api.soundcloud.com/resolve?url=https://soundcloud.com/mtarecords/my-nu-leng-flava-d-soul-shake&client_id=CLIENT_ID

returns

https://api.soundcloud.com/tracks/249638630?client_id=CLIENT_ID

SteveE
  • 168
  • 1
  • 6
  • 4
    Neither one of those endpoints returned by the example URLs (with CLIENT_ID replaced) work for me. It resolves to the right track_id/url and attempts to redirect/load the track api data but throws 403 like before. Have attempted using different CLIENT_ID/App and even tried making a new developer account all together. Still, the issues persist with those tracks. – Andrew Mar 15 '16 at 03:37
  • 1
    just liked them on soundcloud, then went to a website I'm developing using the soundcloud API and the tracks did not show up in my "favorites" feed. I added some other tracks after to see if it was a delay on updating the data returned via the API, but neither of the tracks you have issues with are yet to show up in the results from a call to the me/favorites endpoint and the tracks added after them show up without any delay. They do appear as expected on soundcloud, so I would hazard a guess that there is an issue with rights / scope on some tracks via the API. – SteveE Mar 15 '16 at 04:39
  • I'm getting the same issue. The URLs resolve from my local box (Australia) but not from our production boxes (in Arizona). We've done this thousands of times in our app over the last three years and this seems to be fairly new behaviour. I'm able to pull down the URL using curl from the prod boxes but using ruby open-uri blows up. Very strange. My guess is that they've added user agent blocking to some edge servers. – Ponny Mar 18 '16 at 02:06
  • I switched to using Ruby's Faraday lib and it works fine now. Wish I knew why though. – Ponny Mar 18 '16 at 02:20
1

using this url, working perfectly sir. Try this. :D

https://api.soundcloud.com/tracks/TRACK_ID/stream?client_id=CLIENT_ID
1

I have been investigating this issue for some time now, and I discovered something which at least solves my situation, dunno if it will solve yours.

The Revelation: If you do a head request with curl (-I option) then it seems to always return with a 200/300 range response.

Why it works: I am streaming Soundcloud tracks with URLs like https://api.soundcloud.com/tracks/TRACK_ID/stream?client_id=CLIENT_ID in an iOS app using FreeStreamer. The stream was failing on exactly those tracks for which curl -v returned 403 for the tracks URL (it returns 401 for the stream URL). So to solve my situation, I perform a head request which gives 302 Found, extract the mp3 URL, and I use that to stream instead of the original URL.

I consider this a bug of the library (since it should be able to handle any 302) and I created an issue for it.

skensell
  • 1,421
  • 12
  • 21