All api.soundcloud.com URL's give 401 errors #12

Closed
sslotsky opened this Issue Sep 9, 2012 · 11 comments

Comments

Projects
None yet
4 participants

sslotsky commented Sep 9, 2012

I am able to successfully authenticate with oauth and access several API's, such as /me, /tracks, /me/tracks, etc. I am also able to insert the html from a call to client.get('/oembed', :url => track.permalink_url) into my views and the song plays just fine.

But I'm unable to retrieve the song by any other method. Hitting the stream_url, or the download_url, etc, results in a 401 error.

I'm confident I've setup my client correctly, as client.expired? always returns false, and the track I've been trying to download is set to Public and is downloadable. Why am I getting these 401 errors? Thanks!

right there with you

For me though specifically getting 401 when trying to post a comment

Contributor

paulosman commented Nov 23, 2012

@flaminSaganaki Can you provide a code sample? Sounds like your issue might be a bit different than the original.

Contributor

paulosman commented Nov 23, 2012

@flaminSaganaki to clarify, I wasn't able to reproduce your problem using the following code:

require 'soundcloud'

client = Soundcloud.new(:access_token => 'my_access_token')
track = client.get('/me/tracks')[0]
comment = client.post("/tracks/#{track.id}/comments", :comment => { 
  :body => "Hello, thar" 
})

Ill provide a sample shortly, however please checkout the API console
http://developers.soundcloud.com/console
Are you able to get it to respond with anything other than a 401?

Contributor

paulosman commented Nov 24, 2012

@flaminSaganaki Yup. Here are the steps I take to post a comment with the ApiGee Console:

  • Under Authentication, select OAuth. Connect with SoundCloud
  • Request GET /me/tracks
  • Select a track id
  • Request POST /tracks/track_id/comments
  • Replace generated track_id with the one you selected above
  • Add comment[body] parameter and optionally comment[timestamp]

Should be good to go. Let me know if / when you get a code sample that demonstrates the problem.

Ok, I have gotten it working now. But it was painful.

Anyway, one of the first issues with this is that in the docs it specifies the parameters as being simply 'body' and 'timestamp' with no mention of 'comment[body]'. I only saw the comment[body] param when looking at the Java wrapper, and even then, the API console would return 401. It was only when I put it under the "Query" tab of the console that I finally got it to work. Now looking back on the examples in the docs, I can pick out how 'body' would be sorta a node of 'comment' however im not familiar with any of the languages the examples provide.

Either way, all is well now. In my as3 http request, I simply made the two params, 'body' and 'timestamp' to be in the url, not as parameters or headers. Then all the authentication stuff went into headers, and that finally got through.

I'm glad that someone is getting a reply to their issues, but I can't help but wonder if anyone's going to address mine... :D

paulosman closed this in dbc3d33 Dec 4, 2012

Contributor

paulosman commented Dec 4, 2012

@sslotsky Sorry for the late response! Just pushed a new version 0.3.1 that should allow you to access download_url and stream_url. Example code:

require 'soundcloud'

client = Soundcloud.new(:access_token => 'your_access_token')
tracks = client.get('/me/tracks')

data = client.get(tracks[0].download_url)
File.open('output.mp3', 'wb') { |f| f.write(data) }

@paulosman I've been having the same issue. I am trying to download files from soundcloud via the Ruby sdk. The get request on the download_url always gives a nil and I end up getting the nil string error. I did a test using Postman and there the request returned the data.

@track = current_user.soundcloud_client.get(params[:track_uri])
data = current_user.soundcloud_client.get(@track.download_url)
file = File.open("something.mp3","wb"){|f|f.write(data)}

i open the file it has nothing.
I am not sure what the issue is. The closest thing that comes to my mind is that the get request is not returning anything.
The client is well setup. The tracks and profile info display properly.
Please help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment