A simple python script to upload files to dropbox
'''
A very simple program to demonstrate how to upload a file on dropbox
Usage: python upload.py filename
'''
import dropbox
import sys
access_token = 'ACCESS_TOKEN_OBTAINED' # Put the access token obtained from previous file here
client = dropbox.client.DropboxClient(access_token)
print 'linked account: ', client.account_info()
f = open(sys.argv[1], 'rb')
response = client.put_file('/test/'+sys.argv[1], f)
print "uploaded:", response
# Feel free to change it as per your requirements.
'''
Instructions
First go to : https://www.dropbox.com/developers-v1/apps/create
Then create a "Drop ins app" there.
Now go to that from your dropbox apps console to get app_key and app_secret.
'''
import dropbox
app_key = 'APP_KEY_HERE'
app_secret = 'APP_SECRET_HERE'
flow = dropbox.client.DropboxOAuth2FlowNoRedirect(app_key, app_secret)
authorize_url = flow.start()
print '1. Go to: ' + authorize_url
print '2. Click "Allow" (you might have to log in first)'
print '3. Copy the authorization code.'
code = raw_input("Enter the authorization code here: ").strip()
# This will fail if the user enters an invalid authorization code
access_token, user_id = flow.finish(code)
client = dropbox.client.DropboxClient(access_token)
print 'linked account: ', client.account_info()
print "---------One Time Process Done---------"
print "\n"
print "Your access token is:", access_token
# You need to save this access_token obtained in some text file.
# and then refer to upload.py