Skip to content
Dropbox Python SDK support for Flask applications
Failed to load latest commit information.
testapp Fix tests. Jun 19, 2013
.gitignore Add tox config, update travis tests, update default testapp requireme… Jun 19, 2013
.travis.yml Add tox config, update travis tests, update default testapp requireme… Jun 19, 2013
AUTHORS.rst Update readme and authors list. Jun 19, 2013
LICENSE Fix word wrapping in ``LICENSE`` file. May 24, 2012 Update README, add notes on ``DROPBOX_CALLBACK_TEMPLATE`` config var. Apr 21, 2012
README.rst Update badges in README. Jun 19, 2013
TESTING.rst Add notes about test app. Apr 21, 2012 Bump version number. Jun 19, 2013
tox.ini Add tox config, update travis tests, update default testapp requireme… Jun 19, 2013



Dropbox Python SDK support for Flask applications.



$ pip install Flask-Dropbox


Flask-Dropbox is licensed under the BSD License.



REQUIRED. As token would be stored in Flask's session instance, you need to configure secret key for your application.


REQUIRED. App key from Dropbox developer site.


REQUIRED. Secret key from Dropbox developer site.


REQUIRED. Should be 'dropbox' or 'app_folder' as configured for your app.


By default, you don't need to provide this setting, cause Flask-Dropbox will setup callback URL automaticly usign current host and type of request, but if you don't trust us, you could to rewrite this setting manually.


Template to be used for showing errors while trying to process oAuth callback from Dropbox API. By default: 'dropbox/callback.html'.

Next boolean vars could be sent to the template:

  • error_oauth_token - Dropbox API didn't return oAuth token.
  • error_not_equal_tokens - oAuth token from Dropbox API is not equal to request token stored in Flask session.
  • error_response - Dropbox API returns ErrorResponse instance. Also actual exception as error var would be sent to the template too.


Page to redirect to after user successfully logged in with Dropbox account. By default: /.


Page to redirect to after user logged out from authenticated Dropbox session. By default: /.


Where to place account info, Dropbox client and Dropbox session instances. In 0.2 and lower all this info stored in flask_dropbox.Dropbox instance, which isn't thread safe, but from 0.3 all these values stored to flask.g. If you need custom storage you can override this setting with object or string which would be imported.


from flask import Flask
from flask.ext.dropbox import Dropbox, DropboxBlueprint

import settings

app = Flask(__name__)

dropbox = Dropbox(app)

SECRET_KEY = 'some-secret-key'
DROPBOX_KEY = 'dropbox-app-key'
DROPBOX_SECRET = 'dropbox-app-secret'
DROPBOX_ACCESS_TYPE = 'app_folder'

from flask import url_for, redirect, request
from werkzeug import secure_filename

from app import app, dropbox

def home():
    return u'Click <a href="%s">here</a> to login with Dropbox.' % \

def success(filename):
    return u'File successfully uploaded as /%s' % filename

@app.route('/upload', methods=('GET', 'POST'))
def upload():
    if not dropbox.is_authenticated:
        return redirect(url_for('home'))

    if request.method == 'POST':
        file_obj = request.files['file']

        if file_obj:
            client = dropbox.client
            filename = secure_filename(file.filename)

            # Actual uploading process
            result = client.put_file('/' + filename,

            path = result['path'].lstrip('/')
            return redirect(url_for('success', filename=path))

    return u'<form action="" method="post">' \
           u'<input name="file" type="file">' \
           u'<input type="submit" value="Upload">' \

Bugs, feature requests?

If you found some bug in Flask-Dropbox library, please, add new issue to the project's GitHub issues.



  • Flask 0.10 support
  • Store account info, Dropbox client and session in thread-safe flask.g storage instead of flask_dropbox.Dropbox instance
  • Introduce DROPBOX_CACHE_STORAGE setting


  • Add init_app method to Dropbox extension class.
  • Do not send dropbox instance for initialization of DropboxBlueprint class.
  • Use current_app.extensions['dropbox'] statement in views for getting initialized Dropbox instance.


  • Add register_blueprint shortcut to initialize DropboxBlueprint with default values in one line.
  • Move Dropbox class from flask.ext.dropbox.utils to flask.ext.dropbox.extension module. But mainly, it wouldn't affected to your code if you used from flask.ext.dropbox import Dropbox statements.


  • Add dropbox library as install requirement in
  • Update project short description.


  • Fix handling templates while installing via


  • Add support of Dropbox SDK 1.4.1


  • Check that access token is the instance of oauth.OAuthToken class if it exists in session.


  • Initial release.
Something went wrong with that request. Please try again.