Skip to content

Instantly share code, notes, and snippets.

@schlamar
Created December 4, 2013 17:01
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 schlamar/7791242 to your computer and use it in GitHub Desktop.
Save schlamar/7791242 to your computer and use it in GitHub Desktop.
Dropbox authentication with Python SDK,
import webbrowser
from dropbox import client
APP_KEY = ''
APP_SECRET = ''
def authorize():
auth_flow = client.DropboxOAuth2FlowNoRedirect(APP_KEY, APP_SECRET)
authorize_url = auth_flow.start()
webbrowser.open(authorize_url)
print "1. Click \"Allow\" (you might have to log in first)."
print "2. Copy the authorization code."
auth_code = raw_input("Enter the authorization code here: ").strip()
access_token, user_id = auth_flow.finish(auth_code)
print 'User id: %s' % user_id
return access_token
def main():
access_token = authorize()
print 'Using token', access_token
c = client.DropboxClient(access_token)
print c.account_info()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment