Need to see if your shared folder is taking up space on your dropbox šØāš»? Find out how to check here.
Forum Discussion
rsd20
6 years agoExplorer | Level 3
API App Authentication Get List of files/folders from public link
Hi i'm looking for some advice on how to do the following and what best route of authentication / api end points I should use,
I need to be able to parse a dropbox business folder (can do this via a public shared link) for specific files to download which i then need to migrate data to a backoffice system. This would be a background service without user interaction.
What would be the best way to do this with the API and .net SDK?
14 Replies
Replies have been turned off for this discussion
- Greg-DB6 years ago
Dropbox Community Moderator
If you have a shared link for a folder and want to programmatically list its contents using the .NET SDK, you should use the ListFolderAsync/ListFolderContinueAsync methods, and supply the 'path' and 'sharedLink' parameters to ListFolderAsync. The 'path' parameter value should be the empty string if you want to list the contents of the folder root itself, or a relative path like "/subfolder" if you want to list the contents of a subfolder.
To download a file from a shared link, you should use the GetSharedLinkFileAsync method. You can supply just the 'url' parameter if the shared link is for the file itself, or both the 'url' and 'path' parameters if the shared link is for a folder and you want to download a specific file, identified by a particular relative path in 'path'.
- rsd206 years agoExplorer | Level 3
Hi Greg
Thank you for the response. I am struggling to find a way of authenticating without user interaction. As this service will need to run nightly and pull data files from drop box.
- Greg-DB6 years ago
Dropbox Community Moderator
The initial authentication/authorization flow does require manual user interaction, but you can store and re-use the resulting access token after that for future use without further manual user interaction.
- rsd206 years agoExplorer | Level 3
If i use the access token generated in the app admin console is this sufficient? What lifespan does it have?
- Greg-DB6 years ago
Dropbox Community Moderator
You can use an access token generated from the app's page on the App Console to connect to your own account.
Note that depending on the app's configuration, the access token may be short-lived (expires after four hours) or long-lived (doesn't expire by itself). If you don't yet have the "Access token expiration" option on that page, your access token will be long-lived. You can also tell from the access token itself. If it starts with "sl.", it is short-lived. You can find more information in the OAuth Guide.
- rsd206 years agoExplorer | Level 3
I understand that the auth code retrieved form manual user interaction can only be used once.
If at this stage I go and get a token anrefresh token. Is it expected to just keep these tokens and keep refreshing as and when I need to. long does the refresh token last?
Is there no way to get a bearer token from just the app key and secret, it seems that the api doesnt cater for background applications?
- Greg-DB6 years ago
Dropbox Community Moderator
The Dropbox API doesn't offer a way to get an access token automatically, just from an app key and secret. If you need "background", sometimes called "offline", access like this, you should get and store the refresh token like you described. The refresh token doesn't expire by itself (though can be revoked on demand), so you can store and re-use that to get new access tokens as needed, without manual user interaction.
- tribalneck20006 years agoExplorer | Level 3
Is this achievable via the .NET client or only via straight http calls?
- Greg-DB6 years ago
Dropbox Community Moderator
tribalneck2000 All of the functionality discussed above is available both via the API v2 HTTPS endpoints themselves, as well as the official Dropbox API .NET SDK.
- tribalneck20006 years agoExplorer | Level 3
Where can I find a sample of exchanging the refresh token for an access token via the .NET API? I have been looking at the repo: https://github.com/dropbox/dropbox-sdk-dotnet
About Discuss Dropbox Developer & API
Make connections with other developers
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
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!