Created
January 8, 2013 15:29
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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