node-oauth
node-oauth copied to clipboard
Had to change requests writes to binary to fix dropbox-node issue.
Hello,
Ran into an issue with file uploads using dropbox-node which depends on node-oauth oauth.js. I had to change the request.write
calls to write in binary
to get non-ascii file uploads (images, pdfs etc) to work. View the issue here. Not sure if this is something you want to adopt or if it will have implications with other oauth APIs, but the Dropbox Oauth api will not work with non-ascii files unless the request is written in binary.
Thanks,
Ralph
Similarly, the fact that GETs are defaulted to utf8 prevents the ability to correctly download binary data (i.e. via dropbox-node's getFile
and getThumbnail
functions).
I had the same problem. Please just fix this issue, I lost ~2 hours on it.
At the very least you could make this configurable -- in the meantime, I'll be forking this repo and doing a rewrite to fix this.
K. So I don't quite understand, if you pass a buffer to node-oauth's put/post no utf8 encoding should be applied, is that not working ? (if a string is passed then utf8 encoding will be applied atm)
Are you sure about that? If you pass in a Buffer as the post_body
param, you assign its value to extra_params
on line 426 of oauth.js. Then later in _prepareParameters
you iterate over the "keys" of extra_params
, which hangs indefinitely.
Am I supposed to pass in an object with the Buffer keyed by some specific string?
Ah, yes that looks to be a bug :( that test should be checking for an object literal, not !=string ..
Any update on this? I've spent some time poking at oauth.js and I think the issue is deeper simply changing the predicate. After doing so, the request URL somehow gets garbled, as Dropbox generates 400s due to invalid filename parameters.
:( I'm sorry it dropped off my radar (again) been mad busy recently (no excuse I know) .. are drop-box accounts free?
No worries, I know how it goes. Yes, Dropbox accounts are free. If you're intending to play around with dropbox-node, you'll have to register a dummy app to get an API key+secret pair.
I guess I'll start with the raw API and see if I can spot something thats bubbling upto your facade ?
Still an issue, I have a 3rd party api that returns a PDF from a get request. Will see how hard it is to fix and submit a PR. Is this project still being maintained?
@Dakuan Get it working?
@philals sure did: https://github.com/Dakuan/node-oauth/commits/master
Thanks for the @Dakuan
From what I see your changes make the returned data always binary rather than utf8. Is that the case? (https://github.com/ciaranj/node-oauth/compare/master...Dakuan:master#diff-84fad1d3b3913ec86805e857580c5d54R404)
I'm trying to use the same lib for application/json and application/pdf
we are doing just that for in our case - for the xero api as it happens :) - i sent you a message on linkedin too
Well.. looks like we have things in common.
For those that get here from google. Here is how I have managed to GET an invoice.
You must also create an Oauth object and pass in the accept header = application/pdf see here: https://github.com/ciaranj/node-oauth/issues/106