dropbox / dropbox-sdk-js

The Official Dropbox API V2 SDK for Javascript
https://www.dropbox.com/developers
MIT License
941 stars 353 forks source link

support proxy settings #150

Open gildas opened 7 years ago

gildas commented 7 years ago

Since you guys use superagent for your http requests, why not adding proxy support?

I have customers that allow outbound traffic only through their proxy. Which means, they cannot use Dropbox with my code at the moment.

Basically, just use superagent-proxy like this:

var request = require('superagent');

require('superagent-proxy')(request);

downloadRequest = function (path, args, auth, host, accessToken, selectUser, proxy) {
  . . .
  apiRequest = request.post(getBaseURL(host) + path) . . .;

  if (proxy) apiRequest.proxy(options.proxy);
  . . .

The proxy parameter should be configured in the Dropbox constructor.

Thoughts?

greg-db commented 7 years ago

Thanks for writing this up! I can't make any promises, but I'll send this feature request along to the team.

gildas commented 7 years ago

Thanks @greg-db If you want I am happy to work on a PR.

greg-db commented 7 years ago

We always appreciate pull requests! Thanks!

gildas commented 7 years ago

Ok, I'll see what I can do within the next few days.

gildas commented 7 years ago

Here you go @greg-db, PR #151.

greg-db commented 7 years ago

Thanks Gildas!

gildas commented 7 years ago

No problem. Though, it seems like the travis ci job keeps failing.

> eslint src --ignore-path src/types.js
/home/travis/build/dropbox/dropbox-sdk-js/node_modules/superagent-proxy/node_modules/proxy-agent/node_modules/pac-proxy-agent/node_modules/socks-proxy-agent/node_modules/agent-base/index.js:8
const inherits = require('util').inherits;
^^^^^
SyntaxError: Use of const in strict mode.

I am afraid the eslint config is too strict for the external superagent-proxy module.

greg-db commented 7 years ago

Thanks, we'll take a look.

gildas commented 7 years ago

thanks a lot!

gildas commented 7 years ago

I should be around for an hour more or so (I am in Japan, so it is late here)

pran1990 commented 7 years ago

Hey @gildas we should be able to close this when I make a new release in a few hours. Let me know if you disagree.

kevindice commented 6 years ago

I would be interested in this feature. Just not sure what about the PR broke things.

pran1990 commented 6 years ago

@kevindice a possible reason is that we moved form using superagent to fetch. Can you try https://www.npmjs.com/package/fetch-with-proxy and let me know if that works for your usecase? If so, I'll add a section about proxies in the docs.