Dropbox module and access token
The DropboxSession (sess in the code above) object has a set_token() method used as:
which says it will attach an access token to the DropboxSession. That sounds perfect, except the Dropbox app page only generates an access token and says nothing about an access secret.
The generated access token I have is 64 characters long. After the first 32 characters there is an underscore which is then followed by 31 more characters.
Can my access token be used somehow with the set_token method?
MTcoder last edited by
Dropbox is migrating to SDK API v2. The Dropbox module in Pythonista is for SDK API v1. That probably explains the disconnect between my token and the API I am referencing.
I was able to get an access key and secret by running the example script and logging in and printing them (access_token.key and access_token.secret). Using these with the set_token() method and removing all the authentication stuff works just fine. These v1 key and secret strings are 16 and 15 in length.
How do I put in an official request to include Dropbox SDK API v2 in Pythonista? It's a little ugly as both versions need to be around during transition time.
I could be wrong, but this is just the official dropbox python sdk, which omz shipped with pythonista. In the beta,
dropbox.__version__is 6.4, which is the latest. This supports both v1 and v2 api, with different methods. I suspect the example code you are using is outdated... You can use v2 with:
instead of dropbox.client.Dropbox (which is v1)
What version do you have? If that syntax does not work, you can use stash to
pip import dropbox
@JonB Thank you for your attempts to help, and I apologize if I didn't explain things clearly. I am running the latest version of Pythonista, which I think is only for iOS devices. I am using an iPad. I have no idea what version of the Dropbox SDK module I have, as
dropbox.__version__does not exist. I have whatever was packaged with Pythonista. From the method calls it is clearly API v1, but beyond that I cannot tell you.
I think the example code is correct for the version it is packaged with. It is right out of the Pythonista documentation. The newer method for which you gave an example does not exist in this version. Back to my original question, I think the 64-character access key generated by Dropbox is not of any use to me here. But what I captured after my login seems to work.
stash? pip? Thank you for the suggestion, but I only have an iPad anymore.
Thanks again, truly. I'll try to keep going on my project with whatever I have in hand.
ccc last edited by ccc
import dropbox print(dropbox.__version__)
This has worked on all Pythonista versions that have dropbox. See: https://github.com/cclauss/pythonista-module-versions
Okay, sorry, I forget that not everyone knows about or uses stash. See the readme at that link for a one liner that you can copy/paste into the pythonista console, which will install it. StaSH is a commandline shell, which adds several features to pythonista, one of the very useful ones is the pip command, which lets you install many third party python packages.
Install StaSH, restart pythonista, then run the launch_stash.py which appears in your documents folder. Then, type
pip install dropbox
which will install the latest released dropbox sdk into your site-packages folder. Thereafter, when you use import dropbox, it will use the updated package, and you can use the new syntax.
Incidentally, @omz, did you update
dropboxin the pythonista 2.1 hitting the app store soon? 201009 still has the old version.
@ccc check again, in 2.0 there is no version (pythonista_versions returns ????)
@JonB Thank you so much for the stash information. Now your reply makes total sense. Yes, not everyone finds all the little Pythonista nuggets. Just have to keep turning over the rocks. Thanks again.
MTcoder last edited by
@SimCityWok Since you have your access token you should be in good shape, especially with Pythonista 2.1.
Take a look at Dropbox API Explorer in the Dropbox developer's area. It allows you to play and access your dropbox and generate code with just your token in hand.
Good luck -- I hope you can get in again.