Skip to content

Instantly share code, notes, and snippets.

@jerem
Created January 8, 2013 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerem/4484660 to your computer and use it in GitHub Desktop.
Save jerem/4484660 to your computer and use it in GitHub Desktop.
This is a sample code that shows how to use an HTTP proxy with dropbox sdk for Python.
# Include the Dropbox SDK libraries
import httplib
from dropbox import client, rest, session
# Proxy settings
HTTP_PROXY_HOST = '127.0.0.1'
HTTP_PROXY_PORT = 8888
# Get your app key and secret from the Dropbox developer website
APP_KEY = 'XXXXX'
APP_SECRET = 'XXXXX'
# ACCESS_TYPE should be 'dropbox' or 'app_folder' as configured for your app
ACCESS_TYPE = 'dropbox'
# User tokens
USER_TOKEN = 'XXXXX'
USER_SECRET = 'XXXXX'
class MyHTTPConnection(httplib.HTTPConnection):
def __init__(self, host, port):
httplib.HTTPConnection.__init__(self, HTTP_PROXY_HOST, HTTP_PROXY_PORT)
class MyRESTClient(rest.RESTClient):
IMPL = rest.RESTClientObject(http_connect=MyHTTPConnection)
sess = session.DropboxSession(APP_KEY, APP_SECRET, ACCESS_TYPE)
sess.set_token(USER_TOKEN, USER_SECRET)
client = client.DropboxClient(sess, MyRESTClient())
print "linked account:", client.account_info()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment