4

Could someone show some example about using dropbox api with django? Dropbox api is installed, readme is done, tests are done, how to go further?

2
  • 1
    What, exactly, do you want to do? Commented Jun 22, 2011 at 11:02
  • Downvotes for this question are undeserved, but the question does need more detail. Commented Jun 23, 2011 at 6:12

2 Answers 2

6

Yes, you need to understand, how oauth works. Consider the use-case, when you are trying to store uploaded files directly on user's dropbox account. First of all, you have to register a developer account on dropbox site. In your django views, a typical workflow is this:

  1. ask dropbox for a request token, (it notifies them that you will use their api soon)

    dba = auth.Authenticator(app_settings.CONFIG)

    request_token = dba.obtain_request_token()

    it's in the api's documentation how to set up the config file

  2. than you build an authentication url:

    authorize_url = dba.build_authorize_url(request_token, callback='http://...'

    the user sign in at dropbox.com, than redirected back to your site

    you should store now the request token, but it's only useful to get the access token!

  3. you use the request token to get an access token, it's now unique to the user.

    access_token = dba.obtain_access_token(request_token, 'verifier')

    leave the verifier blank, it's preserved do future usage! store the access token, you need it in any further operation(per session)

  4. here you are! you should instantiate a client, it's defined in the python-specific dropbox package

    drpbx_client = client.DropboxClient('server','content_server','port',dba,access_token)

    the client is a helper object for file operations:

    drpbx_client.put_file('dropbox', '/porn/', request.FILES['file'])

Sign up to request clarification or add additional context in comments.

3 Comments

From the FAQ: Civility is required at all times; rudeness will not be tolerated.
Is it possible to browse the folder list in Dropbox and create subfolders?
5

You must use the Dropbox REST api:

http://www.dropbox.com/developers/docs#api-specification

It uses oauth for authentication. Detailed guide and walkthrough can be found here:

http://hueniverse.com/oauth/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.