#NEWLINE# def command_dropbox_connect( args ) : #NEWLINE# #INDENT# import dropbox #NEWLINE# if ( args . spellbook_name is not None ) : #NEWLINE# #INDENT# print ( 'ERR: sync is only for all books' ) #NEWLINE# return #NEWLINE# #UNINDENT# app_key = 'ow3gosk8pb9bhkr' #NEWLINE# app_secret = 'w3eqoqx5scb64pd' #NEWLINE# flow = dropbox . DropboxOAuth2FlowNoRedirect ( app_key , app_secret ) #NEWLINE# authorize_url = flow . start ( ) #NEWLINE# print ( ( '1. Go to: ' + authorize_url ) ) #NEWLINE# print ( '2. Click "Allow" (you might have to log in first)' ) #NEWLINE# print ( '3. Copy the authorization code.' ) #NEWLINE# code = collect_str ( 'the authorization code here' ) #NEWLINE# ( access_token , user_id ) = flow . finish ( code ) #NEWLINE# client = dropbox . Dropbox ( access_token ) #NEWLINE# print ( 'successfully linked account: ' , client . users_get_current_account ( ) . name . display_name ) #NEWLINE# with open ( DROPBOX_TOKEN_PATH , 'w' ) as fout : #NEWLINE# #INDENT# fout . write ( access_token )