SoundCloud, download or stream file via api - audio

I try to use download_url to get file from soundcloud.
I either get 'redirected' or '401 unauthorized', how can I download/stream it to client side?
thanks

If you are getting a 401 response, then you should include your client_id in the request. It might also be that it's a private sound, in which case, you'd also have to include the oauth credentials.
The actual success response is a redirect, since the stream files are accessible from a different server, but only with special time-limited access tokens (included in the redirect response). Basically, just follow the redirect and you'll have your stream.

You are using Wrong Url Structure...
Try This ,Its Working (I tested) :
http://api.soundcloud.com/tracks/773150/download?client_id={Your ID Here}
You Should Use ? Instead Of & before client_id

Related

How to use res.redirect to redirect to a data url?

I need to use the res.redirect() to redirect to a data URL using express.
This is my code...
app.get("/",(req,res)=>{
res.redirect("data:text/plain;base64,hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
})
When I use another URL eg: https://www.google.com It works fine.
But when I use a data URL it is not working..
How should I fix it?
I am new to programming and StackOverflow. So, please be kind to me
You could redirect the user to a blob of the dataurl location.
For that just search google for dataurl to blob in js etc.
And also as you are using nodejs you could use the http.request and pipe the response to client just like proxying.
or you could fetch that file with "http.request" and save it in your server and give it when the client needs it
This is likely Chrome issue rather than NodeJS:
https://groups.google.com/a/chromium.org/g/blink-dev/c/GbVcuwg_QjM/m/GsIAQlemBQAJ
In practice, these will be blocked:
Navigations when the user clicks on links in the form of
window.open(“data:…”)
window.location = “data:…”
Meta redirects

node-quickbooks reconnect method no longer gives expected response

I am trying to get new access tokens before they expire using reconnect api endpoint, but the api call to https://appcenter.intuit.com/api/v1/Connection/Reconnect is being redirected to https://quickbooks.intuit.com/learn-support/en-us/do-more-with-quickbooks/third-party-app-security-requirements-updating-soon/01/428295, rather the expected response. Am i missing something here? Appreciate the help.
According to Intuit's documentation, you're using the wrong URL:
https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/oauth-2.0#refresh-the-token
Did you try using the correct URL?
From the docs:
To refresh an access token, your application sends an HTTPS POST request to
Intuit’s authorization server
(https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer)
that includes the following parameters:

How to download an image from Twilio whatsapp API with Node.js

My goal is to get the image from Twilio api to store it somewhere else because Twilio deletes media after 4h.
(See here)
I'm using node and I have read https://www.twilio.com/docs/sms/api/media-resource#fetch-a-media-resource
...and it says that to do a request to this URL without the "json" extension should return the media with its original MIME type
https://api.twilio.com/2010-041/Accounts/{AccountSid}/Messages/{MessageSid}/Media/{Sid}.json
However, i need auth, so I need to use
const client = require('twilio')(accountSid, authToken);
How can I fetch the image? Any sample code to achieve it? In the docs seem to do it without auth.
UPDATE ----------------------------------------
After accessing the MediaUrl0 on the browser, twilio redirects me to the following URL:
https://s3-external-1.amazonaws.com/media.twiliocdn.com/{AccountSid}/{?}
I was thinking of building my own URL but i dont know how to get the {?}
You do not need authentication to retrieve media for an incoming sms . They are all hosted (as of now on Aws S3) and accessible publicly through a (hard to guess) url.
you can access them using any http client

Node Express sending get request on static file in windows with backslash in path

I see that windows uses \ for path. When same request is issued to backend api it works fine but when issued from axios in frontend, it converts \ to %5C.
what happens differently when request is sent from postman and axios.
At front end:
http://myIp:5000/public\images\ImageName.jpeg
At the back end server:
GET /public%5Cimages%5CImageName.jpeg 401
I am not sure if I correctly understand your question, but may lend you something that helps locate the problem.
In the http uri, the only separator is /. So to GET a static file at static\icon.jpg, you fire a GET request to static/icon.jpg
To explain the %5C nonsense, I recommend to read https://en.wikipedia.org/wiki/Percent-encoding. To put it simple, only few characters are allowed to exist in the uri. To expand the charset used in uri, people invented a code scheme. In this scheme, \ is translated to %5C
Postman has built-in fault tolerance which converts \ to / automatically
For Example:
When I intentionally typed wrong in URL
To Check what Postman send to your back-end: click code button (present under save button)
you can see the corrected URL
Axios is a REST Client which doesn't do anything to correct URL but convert it and make a REST Call.
The main differences is that Postman Corrects the URL before making a REST Call but Axios doesn't.
Looking at the answers above.This worked for me. Simply replace %5C with /
filepath = filepath.replace(/%5C/g, "/");

Unable to get redirect response from Node server using res.writeHead() and .end()

I'm writing a server in Node.js. I've been using the send-data/json package to send responses, with much success. For example, at the end of my API call I use this code:
sendJson(res, res, {some: content})
This works great. However, I have a need to implement a URL redirect in one of my API endpoints. The code I am seeing everywhere to do this looks like this:
res.writeHead(302, {Location: 'http://myUrl.com'})
res.end()
However, this change causes my server to stop sending responses on this endpoint.
What am I missing?
Note: this is vanilla Node without Express.
Update: to clarify, based on contributions in the comments, this is the result of a GET request, so I expect that redirects should be enabled by default. I am still curious why no response is coming back from the server at all, regardless of whether it is an erroneous redirect attempt or a successful one.

Resources