Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
I am trying to access files stored on my Dropbox using the offical Dropbox SDK for Python.. I tried a few ways of putting in the directory name whose contents I wanted to have listed based off of a script taken from this link https://practicaldatascience.co.uk/data-science/how-to-use-the-dropbox-api-with-python. Following the instructions in this website, I created an App, generated a dropbox access token (which produced 'long-gibberish'), and gave myself read permissions for Files and Folders.
When I login to Dropbox through the website, the folder structure for the folder that I want to access looks like so: Folder/ SubFolder/ SubSubFolder.
I get the following error when calling the function:
dropbox_list_files('Folder/SubFolder/SubSubFolder') Error getting list of files from Dropbox: ApiError('short-gibberish', ListFolderError('path', LookupError('not_found', None)))
DROPBOX_ACCESS_TOKEN = 'long-gibberish' def dropbox_connect(): """Create a connection to Dropbox.""" try: dbx = dropbox.Dropbox(DROPBOX_ACCESS_TOKEN) except AuthError as e: print('Error connecting to Dropbox with access token: ' + str(e)) return dbx def dropbox_list_files(path): """Return a Pandas dataframe of files in a given Dropbox folder path in the Apps directory. """ dbx = dropbox_connect() try: files = dbx.files_list_folder(path).entries files_list = [] for file in files: if isinstance(file, dropbox.files.FileMetadata): metadata = { 'name': file.name, 'path_display': file.path_display, 'client_modified': file.client_modified, 'server_modified': file.server_modified } files_list.append(metadata) df = pd.DataFrame.from_records(files_list) return df.sort_values(by='server_modified', ascending=False) except Exception as e: print('Error getting list of files from Dropbox: ' + str(e))
I would like to get some help on how to set the right path.
OMG!
Yes, such things don't have to be shared (can be dangerous - direct access to your account on the wider public)!
That what you are sharing looks like access token. It's NOT application key.
The application key is ID of the application you have registered. You need this key, not the access token. The last error comes from erroneous places free text on place where client ID is expected (nothing related to access token). You application ID (or key) can be seen on your application page when you select your application here (the same link I post above, but seems you skipped it). Find out your application key there and put it on the APP_KEY var initialization into the example.
Hope now all will be Ok.
@sambapy wrote:...
When I login to Dropbox through the website, the folder structure for the folder that I want to access looks like so: Folder/ SubFolder/ SubSubFolder.
...
Hi @sambapy,
Base on names posted by you (i.e. starting from your account root - Folder > SubFolder > SubSubFolder), the string describing the path should look like "/Folder/SubFolder/SubSubFolder". 😉 That's it.
Good luck.
About access token: No, it 's not related in any way to your login (once the token already issued). Access token itself expires after 4 hours, at most! If you want long term access, you need refresh token too (together with access token).
Is a token sufficient to establish connection with my Dropbox or is there any other step before that?
If you mean, what's needed to authenticate a regular call to API endpoint, Yes - valid access token is enough. As I said access token validity is limited in time to no more than 4 hours (could be less) - exact period is denoted on access token receiving. If you mean, additional steps for long term access, refreshing is usually performed automatically by SDK itself, but you need to supply refresh token on client object (dbx) realization (not access token only).
Do I need some special permissions to download the files using this API, if I am a newly added member to the Dropbox group? I have given myself the permission for files.content.read.
@sambapy wrote:Do I need some special permissions to ...
If you mean scopes, Yes (but they are not special 🙂). Every operation falls to some group that expect particular scope. Your application (and all associated tokens) needs granted appropriate set of scopes to be able perform needed operations. Scopes can be changed in your application page here (go to Permissions tap). The same (or needed, at least) scopes need to be granted on authorization time! Take in mind once a scope gets changed, new token are needed, so any changes can take effect (such type of changes are NOT retroactive).
One more thing. When you try files listing (such operations are granted by default), take in mind that first call does NOT mandatory return entire result, you may need to call follow up list continuation calls.
Don't try to interpret things you don't intend to use (like openID for instance). 😉 Go further with the basics (initially least).
This is what my OpenID Scopes reads:
Scopes used for OpenID Connect.
For an example using Python, take a look here. You can keep the refresh token and use for follow up instantiation without full OAuth flow. Just put file listing procedure on the place of 'users_get_current_account' method there. 😉
Hope this helps.
Thanks for sticking around, and patiently responding to my queries.
I get the following error:
Error (400)
It seems the app you were using submitted a bad request. If you would like to report this error to the app's developer, include the information below.
More details for developers
Invalid client_id: "this is long-gibberish"
Oh @sambapy, Be more careful!!!
What's this: this is long-gibberish ??? 🤦 Seems you have NOT made even a small try to get familiar with structure of such code and just trying to "shot on directions". Take the real client id (or app key too) and put it there. Follow the same rule on all other places where you have to put something!
🙋 Fake ID -> Error (of course - can be expected 😁 - would be strange if passed - real security HOLE)
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!