refactor: use new API authentification #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi! First of all, thank you for creating this awesome tool!
This player works way better than the one provided by the (now deprecated) SoundCloud's Javascript SDK. I've been using your library in my project for a long time and it's been working great:
https://github.com/alexandre-abrioux/soundcloud-reverse
Unfortunately, and because of the latest SoundCloud's API security update, I noticed this week that playback is not working anymore.
SoundCloud now requires an
Authorization
header containing an OAuth token on each request made to its API.Furthermore it looks like legacy stream URLs like
https://api.soundcloud.com/tracks/[ID]/stream
are not playable anymore, because they also need thisAuthorization
header, rendering them unusable (details bellow).If you try to send an
Authorization
header to the stream with some audio tag hack (cf. this Stackoverflow thread), it won't work because those stream URLs do a 302 redirect to a CDN that won't accept theAuthorization
header, however the browser will send it, thus creating a CORS failure. There is no way to manually handle the redirection with xhr requests, even when using fetch'sredirect=manual
option, as this is a security feature from the spec.This is why we have to use the new API endpoint
/tracks/[ID]/streams
(notice thes
at the end of stream) to first get the CDN url and then use it as the audio source.I'm using it now on my project and playback works again:
You just need to pass an OAuth token now instead of a
client_id
:TL;DR: This is a refacto of the codebase that takes into consideration the new SoundCloud API update