<s> import flask <EOL> import auth <EOL> import config <EOL> import model <EOL> import util <EOL> from main import app <EOL> dropbox_config = dict ( <EOL> access_token_method = '<STR_LIT:POST>' , <EOL> access_token_url = '<STR_LIT>' , <EOL> authorize_url = '<STR_LIT>' , <EOL> base_url = '<STR_LIT>' , <EOL> consumer_key = config . CONFIG_DB . dropbox_app_key , <EOL> consumer_secret = config . CONFIG_DB . dropbox_app_secret , <EOL> ) <EOL> dropbox = auth . create_oauth_app ( dropbox_config , '<STR_LIT>' ) <EOL> @ app . route ( '<STR_LIT>' ) <EOL> def dropbox_authorized ( ) : <EOL> response = dropbox . authorized_response ( ) <EOL> if response is None : <EOL> flask . flash ( '<STR_LIT>' ) <EOL> return flask . redirect ( util . get_next_url ( ) ) <EOL> flask . session [ '<STR_LIT>' ] = ( response [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> me = dropbox . get ( '<STR_LIT>' ) <EOL> user_db = retrieve_user_from_dropbox ( me . data ) <EOL> return auth . signin_user_db ( user_db ) <EOL> @ dropbox . tokengetter <EOL> def get_dropbox_oauth_token ( ) : <EOL> return flask . session . get ( '<STR_LIT>' ) <EOL> @ app . route ( '<STR_LIT>' ) <EOL> def signin_dropbox ( ) : <EOL> return auth . signin_oauth ( dropbox , '<STR_LIT>' ) <EOL> def retrieve_user_from_dropbox ( response ) : <EOL> auth_id = '<STR_LIT>' % response [ '<STR_LIT>' ] <EOL> user_db = model . User . get_by ( '<STR_LIT>' , auth_id ) <EOL> if user_db : <EOL> return user_db <EOL> return auth . create_user_db ( <EOL> auth_id = auth_id , <EOL> name = response [ '<STR_LIT>' ] , <EOL> username = response [ '<STR_LIT>' ] , <EOL> ) </s>
