node-oauth icon indicating copy to clipboard operation
node-oauth copied to clipboard

Had to change requests writes to binary to fix dropbox-node issue.

Open ralphholzmann opened this issue 13 years ago • 16 comments

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

ralphholzmann avatar Mar 29 '11 16:03 ralphholzmann

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).

evnm avatar Mar 29 '11 18:03 evnm

I had the same problem. Please just fix this issue, I lost ~2 hours on it.

fb55 avatar Jun 05 '11 16:06 fb55

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.

ralphholzmann avatar Jul 15 '11 14:07 ralphholzmann

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)

ciaranj avatar Jul 29 '11 21:07 ciaranj

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?

evnm avatar Aug 03 '11 03:08 evnm

Ah, yes that looks to be a bug :( that test should be checking for an object literal, not !=string ..

ciaranj avatar Aug 03 '11 05:08 ciaranj

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.

evnm avatar Aug 25 '11 03:08 evnm

:( I'm sorry it dropped off my radar (again) been mad busy recently (no excuse I know) .. are drop-box accounts free?

ciaranj avatar Aug 25 '11 20:08 ciaranj

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.

evnm avatar Aug 25 '11 21:08 evnm

I guess I'll start with the raw API and see if I can spot something thats bubbling upto your facade ?

ciaranj avatar Aug 25 '11 21:08 ciaranj

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 avatar Dec 20 '16 19:12 Dakuan

@Dakuan Get it working?

philals avatar Feb 16 '18 07:02 philals

@philals sure did: https://github.com/Dakuan/node-oauth/commits/master

Dakuan avatar Feb 16 '18 07:02 Dakuan

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

philals avatar Feb 16 '18 07:02 philals

we are doing just that for in our case - for the xero api as it happens :) - i sent you a message on linkedin too

Dakuan avatar Feb 16 '18 08:02 Dakuan

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.

image

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

philals avatar Feb 16 '18 08:02 philals