kipwoker / SoundCloud.API.Client

It's .NET client for SoundCloud API https://developers.soundcloud.com/docs/api/reference
52 stars 14 forks source link

Getting a 403 error when trying to stream track #1

Open sixkilleraz opened 9 years ago

sixkilleraz commented 9 years ago

I'm getting strange behavior when trying to access the track stream. The is further complicated by the fact that it is not consistent across all tracks. Some tracks will occasionally work, and then stop. I have a slightly better experience when running this locally, vs on my hosting platform (godaddy).

Here's the code:

        public FileStreamResult Track(string id) {
            var clientId = ConfigurationManager.AppSettings["soundCloudClientId"];
            var clientSecret = ConfigurationManager.AppSettings["soundCloudClientSecret"];
            var username = ConfigurationManager.AppSettings["soundCloudUserName"];
            var password = ConfigurationManager.AppSettings["soundCloudPassword"];

            ISoundCloudConnector soundCloudConnector = new SoundCloudConnector();
            var soundCloudClient = soundCloudConnector.DirectConnect(clientId, clientSecret, username, password);
            using (var fileStream = soundCloudClient.Track(id).GetStream()) {
                return new FileStreamResult(fileStream, "audio/mpeg");
            }
        }
kipwoker commented 9 years ago

Are you that your track isn't private? Please send me track id. I will try to reproduce it.

sixkilleraz commented 9 years ago

I now don't think this has anything to do with your SDK, I wrote a quick bit of code to get the streaming redirect url from the track's stream_url. I find that sometimes the url will throw an 'invalid signature' error. Which puzzles me, since the link is generated from soundcloud.

Here are tracks from one of our albums. These are all public: https://api.soundcloud.com/tracks/190613982/stream https://api.soundcloud.com/tracks/190614460/stream https://api.soundcloud.com/tracks/190614417/stream https://api.soundcloud.com/tracks/190634160/stream https://api.soundcloud.com/tracks/190614339/stream https://api.soundcloud.com/tracks/190612009/stream https://api.soundcloud.com/tracks/190614800/stream https://api.soundcloud.com/tracks/190614360/stream https://api.soundcloud.com/tracks/190611995/stream

I can't be certain, but it looks like the issue occurs when the signature has non alpha-numeric characters in it.

I posted this on Stack Overflow in hopes that they dev team can explain what is happening: http://stackoverflow.com/questions/28732916/soundcloud-stream-url-returns-403-error-signature-does-not-match

kipwoker commented 9 years ago

Check out my commit https://github.com/kipwoker/SoundCloud.API.Client/commit/7a4a893b3d87ac50899defdd9df13bde61e813b1

I wrote test for this issue. Seems like it's soundcloud (not client) error. So will wait answer for your question on SO. :)

sheriffderek commented 8 years ago

+1 Suddenly one of our sites is 403 latakedown.com EDIT - turns out the 'client' bungled something on their end.