Created
December 4, 2013 17:01
-
-
Save schlamar/7791242 to your computer and use it in GitHub Desktop.
Dropbox authentication with Python SDK,
This file contains 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
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