Load and play privately-shared tracks via the API

1,759 views
Skip to first unread message

Diana Kimball

unread,
Feb 5, 2012, 8:03:19 PM2/5/12
to soundc...@googlegroups.com
Hi Johannes and crew,

I'm trying to load & play privately-shared tracks via the API for a web app I'm building, but I'm running into some trouble. 

The basic scenario:

1. Authenticate the user
2. Iterate over all tracks shared privately with that user to find those whose title contains a certain string
3. Load those tracks into a playable list

I'm using the SoundCloud Ruby wrapper, the SoundCloud strategy for OmniAuth for authentication, and the SoundCloud custom player to load and play tracks within my web app. 

The problem I'm running into is that the SoundCloud custom player accepts standard permalinks for tracks (e.g. http://soundcloud.com/dianakimball/you-you-you-you-you ), and it will play private tracks when passed a permalink with secret token (e.g. http://soundcloud.com/bryan/summer-of-69?secret_token=s-ykwdd&client_id=YOUR_CLIENT_ID ). But as far as I can tell, the SoundCloud custom player won't play private tracks created by other people and shared with me unless I have the per-song secret token…which can only be generated by the track's creator (as far as I can tell). When I try to load tracks shared privately with me via their permalink URLs through the API while authenticated, I get "403 forbidden".

I see at least two possibilities:
1) Playing tracks created by other people but shared privately with me is not supported via the API (seems unlikely)
2) I should be using some other URL type (not the permalink) in order to correctly stream privately-shared tracks while authenticated (in this case, I'd need to know whether the SoundCloud custom player accepts that other URL type, or whether, alternatively, I'll need to find a different template to work from)

Really my only goal is meeting the scenario, so I'm happy to make changes to my app if doing so will enable playing privately-shared tracks via the API.

Thanks for looking into this!

- Diana

Diana Kimball

unread,
Feb 9, 2012, 1:50:50 PM2/9/12
to soundc...@googlegroups.com
Still puzzling over this…any suggestions?

Sub

unread,
Feb 10, 2012, 12:53:56 PM2/10/12
to SoundCloudAPI

Diana Kimball

unread,
Feb 11, 2012, 7:57:12 PM2/11/12
to soundc...@googlegroups.com
Thanks very much for taking the time to reply. It sounds like the earlier thread is about accessing (or preventing access to) private tracks on a website external to SoundCloud, without regard to authentication. I think my case is different in that it deals with loading and playing private tracks *while authenticated* via the API. 

In other words, I want to authenticate a user and then load and play all tracks shared exclusively with that user. I can't seem to do so via the API, since apparently only a track's creator can generate its secret token, and I can't figure out how to play a privately-shared track without that secret token.

And a quick update on status: I spent another couple of hours on this today and I'm still stumped. I'd appreciate any additional suggestions or ideas.

Paul Osman

unread,
Feb 29, 2012, 12:51:52 PM2/29/12
to soundc...@googlegroups.com
Hi Diana,

I reproduced the problem you're having. I wrote some code that authorizes a user, then tries to stream some private tracks that have been shared with them. I'm unable to get the streaming to work with the JavaScript SDK, as it looks like only the client_id is passed as a querystring param when fetching the stream URL (which makes sense, since the oauth_token is secret and shouldn't be used in JavaScript). I am however able to get the stream URL of a private track with curl or another SDK. The following pseudo-code should demonstrate what I'm doing:

client = SoundCloud(access_token=foo)� # access token belongs to user 'a'
track = client.get('/tracks/123')� # track 123 belongs to user 'b' but is shared with user 'a'
print track.stream_url

Does that get you any closer? Maybe you can post the snippet of code you're using?

In terms of listing private tracks, the only thing I can think of is to use the tracks subresource and filter param, but this will only work if you know the user ID of the person sharing the track. For example:

client.get('/users/1234/tracks', { filter: 'private' })

would list all of the users private tracks that have been shared with the authenticated user.

Cheers,
Paul
11 February, 2012 7:57 PM
Thanks very much for taking the time to reply. It sounds like the earlier thread is about accessing (or preventing access to) private tracks on a website external to SoundCloud, without regard to authentication. I think my case is different in that it deals with loading and playing private tracks *while authenticated* via the API.�

In other words, I want to authenticate a user and then load and play all tracks shared exclusively with that user. I can't seem to do so via the API, since apparently only a track's creator can generate its secret token, and I can't figure out how to play a privately-shared track without that secret token.

And a quick update on status: I spent another couple of hours on this today and I'm still stumped. I'd appreciate any additional suggestions or ideas.
--
You received this message because you are subscribed to the Google Groups "SoundCloudAPI" group.
To view this discussion on the web visit https://groups.google.com/d/msg/soundcloudapi/-/JHESu9wOplUJ.
To post to this group, send email to soundc...@googlegroups.com.
To unsubscribe from this group, send email to soundcloudap...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/soundcloudapi?hl=en.
10 February, 2012 12:53 PM
9 February, 2012 1:50 PM
Still puzzling over this�any suggestions? --
You received this message because you are subscribed to the Google Groups "SoundCloudAPI" group.
To view this discussion on the web visit https://groups.google.com/d/msg/soundcloudapi/-/nI2Q9-ScsL0J.
To post to this group, send email to soundc...@googlegroups.com.
To unsubscribe from this group, send email to soundcloudap...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/soundcloudapi?hl=en.
5 February, 2012 8:03 PM
Hi Johannes and crew,

I'm trying to load & play privately-shared tracks via the API for a web app I'm building, but I'm running into some trouble.�

The basic scenario:

1. Authenticate the user
2. Iterate over all tracks shared privately with that user to find those whose title contains a certain string
3. Load those tracks into a playable list

I'm using the SoundCloud Ruby wrapper, the SoundCloud strategy for OmniAuth for authentication, and the SoundCloud custom player to load and play tracks within my web app.�

The problem I'm running into is that the SoundCloud custom player accepts standard permalinks for tracks (e.g.�http://soundcloud.com/dianakimball/you-you-you-you-you ), and it will�play private tracks when passed a permalink with secret token (e.g.�http://soundcloud.com/bryan/summer-of-69?secret_token=s-ykwdd&client_id=YOUR_CLIENT_ID ). But as far as I can tell, the SoundCloud custom player won't play private tracks created by other people and shared with me unless I have the per-song secret token�which can only be generated by the track's creator (as far as I can tell). When I try to load tracks shared privately with me via their permalink URLs through the API while authenticated, I get "403 forbidden".

I see at least two possibilities:
1) Playing tracks created by other people but shared privately with me is not supported via the API (seems unlikely)
2) I should be using some other URL type (not the permalink) in order to correctly stream privately-shared tracks while authenticated (in this case, I'd need to know whether the SoundCloud custom player accepts that other URL type, or whether, alternatively, I'll need to find a different template to work from)

Really my only goal is meeting the scenario, so I'm happy to make changes to my app if doing so will enable playing privately-shared tracks via the API.

Thanks for looking into this!

- Diana
--
You received this message because you are subscribed to the Google Groups "SoundCloudAPI" group.
To view this discussion on the web visit https://groups.google.com/d/msg/soundcloudapi/-/yQP9_WxN6WEJ.
To post to this group, send email to soundc...@googlegroups.com.
To unsubscribe from this group, send email to soundcloudap...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/soundcloudapi?hl=en.

Diana Kimball

unread,
Mar 15, 2012, 11:36:14 PM3/15/12
to soundc...@googlegroups.com
Thanks for the reply, Paul, and I apologize for the slow response. I've posted code snippets and an up-to-date explanation here:


In short, I'm now able to get the stream_url as you suggest, but sc-player.js doesn't seem to want stream URLs. I'd be happy to be wrong, though. :)

- Diana

On Wed, Feb 29, 2012 at 10:51 AM, Paul Osman <os...@soundcloud.com> wrote:
Hi Diana,

I reproduced the problem you're having. I wrote some code that authorizes a user, then tries to stream some private tracks that have been shared with them. I'm unable to get the streaming to work with the JavaScript SDK, as it looks like only the client_id is passed as a querystring param when fetching the stream URL (which makes sense, since the oauth_token is secret and shouldn't be used in JavaScript). I am however able to get the stream URL of a private track with curl or another SDK. The following pseudo-code should demonstrate what I'm doing:

client = SoundCloud(access_token=foo)  # access token belongs to user 'a'
track = client.get('/tracks/123')  # track 123 belongs to user 'b' but is shared with user 'a'

print track.stream_url

Does that get you any closer? Maybe you can post the snippet of code you're using?

In terms of listing private tracks, the only thing I can think of is to use the tracks subresource and filter param, but this will only work if you know the user ID of the person sharing the track. For example:

client.get('/users/1234/tracks', { filter: 'private' })

would list all of the users private tracks that have been shared with the authenticated user.

Cheers,
Paul
11 February, 2012 7:57 PM
Thanks very much for taking the time to reply. It sounds like the earlier thread is about accessing (or preventing access to) private tracks on a website external to SoundCloud, without regard to authentication. I think my case is different in that it deals with loading and playing private tracks *while authenticated* via the API. 

In other words, I want to authenticate a user and then load and play all tracks shared exclusively with that user. I can't seem to do so via the API, since apparently only a track's creator can generate its secret token, and I can't figure out how to play a privately-shared track without that secret token.

And a quick update on status: I spent another couple of hours on this today and I'm still stumped. I'd appreciate any additional suggestions or ideas.
--
You received this message because you are subscribed to the Google Groups "SoundCloudAPI" group.
To view this discussion on the web visit https://groups.google.com/d/msg/soundcloudapi/-/JHESu9wOplUJ.
To post to this group, send email to soundc...@googlegroups.com.
To unsubscribe from this group, send email to soundcloudap...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/soundcloudapi?hl=en.
10 February, 2012 12:53 PM
9 February, 2012 1:50 PM
Still puzzling over this…any suggestions? --
You received this message because you are subscribed to the Google Groups "SoundCloudAPI" group.
To view this discussion on the web visit https://groups.google.com/d/msg/soundcloudapi/-/nI2Q9-ScsL0J.

To post to this group, send email to soundc...@googlegroups.com.
To unsubscribe from this group, send email to soundcloudap...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/soundcloudapi?hl=en.
5 February, 2012 8:03 PM
Hi Johannes and crew,

I'm trying to load & play privately-shared tracks via the API for a web app I'm building, but I'm running into some trouble. 

The basic scenario:

1. Authenticate the user
2. Iterate over all tracks shared privately with that user to find those whose title contains a certain string
3. Load those tracks into a playable list

I'm using the SoundCloud Ruby wrapper, the SoundCloud strategy for OmniAuth for authentication, and the SoundCloud custom player to load and play tracks within my web app. 

The problem I'm running into is that the SoundCloud custom player accepts standard permalinks for tracks (e.g. http://soundcloud.com/dianakimball/you-you-you-you-you ), and it will play private tracks when passed a permalink with secret token (e.g. http://soundcloud.com/bryan/summer-of-69?secret_token=s-ykwdd&client_id=YOUR_CLIENT_ID ). But as far as I can tell, the SoundCloud custom player won't play private tracks created by other people and shared with me unless I have the per-song secret token…which can only be generated by the track's creator (as far as I can tell). When I try to load tracks shared privately with me via their permalink URLs through the API while authenticated, I get "403 forbidden".

I see at least two possibilities:
1) Playing tracks created by other people but shared privately with me is not supported via the API (seems unlikely)
2) I should be using some other URL type (not the permalink) in order to correctly stream privately-shared tracks while authenticated (in this case, I'd need to know whether the SoundCloud custom player accepts that other URL type, or whether, alternatively, I'll need to find a different template to work from)

Really my only goal is meeting the scenario, so I'm happy to make changes to my app if doing so will enable playing privately-shared tracks via the API.

Thanks for looking into this!

- Diana
--
You received this message because you are subscribed to the Google Groups "SoundCloudAPI" group.
To view this discussion on the web visit https://groups.google.com/d/msg/soundcloudapi/-/yQP9_WxN6WEJ.

To post to this group, send email to soundc...@googlegroups.com.
To unsubscribe from this group, send email to soundcloudap...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/soundcloudapi?hl=en.

--
You received this message because you are subscribed to the Google Groups "SoundCloudAPI" group.
postbox-contact.jpg
compose-unknown-contact.jpg
Reply all
Reply to author
Forward
0 new messages