Some days ago, I was faced with the task of developing Dropbox connector that should be able to enumerate and download files from Dropbox. The ideal case for me is a wrapper library for .NET 3.5 with an ability to authorize in Dropbox without user interaction. This is a list of .NET libraries/components that are currently available:
- DropNet (NuGet package)
- SharpBox (NuGet package)
- Spring.NET Social Dropbox
- Xamarin Dropbox Sync component.
Sprint.NET and Xamarin component are not my options for now. DropNet also does not fit my needs, because it is .NET 4+ only. But if your application is for .NET 4+, then DropNet should be the best choice for you. I chose SharpBox, it looks like a dead project – no commits since 2011, but nevertheless the latest version is available on NuGet.
At the beginning, you need to go to Dropbox App Console and create a new app. Click on “Create app” button and answer to the questions like in the picture below.
When you finish all these steps, you will get an App key and App secret, please copy them somewhere – you will need them in future. Now we are ready to create our application. Let’s create a new F# project and add AppLimit.CloudComputing.SharpBox package from NuGet.
After package is downloaded, go to packages\AppLimit.CloudComputing.SharpBox.1.2.0.542\lib\net40-full folder, find and start DropBoxTokenIssuer.exe application.
Fill Application Key and Application Secret with values that you received during app creation, fill Output-File path with c:\token.txt and click “Authorize”. Wait some seconds(depends on your Internet connection) and follow the steps that will appear in browser control on the form – you will need to authorize in Dropbox with your Dropbox account and grant access to your files for your app. When file with your token will be created, you can click on “Test Token” button to make sure that it is correct.
Using token file, you are able to work with Dropbox files without direct user interaction, as shown in the sample below:
open System.IO open AppLimit.CloudComputing.SharpBox [<EntryPoint>] let main argv = let dropBoxStorage = new CloudStorage() let dropBoxConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox) // load a valid security token from file use fs = File.Open(@"C:\token.txt", FileMode.Open, FileAccess.Read, FileShare.None) let accessToken = dropBoxStorage.DeserializeSecurityToken(fs) // open the connection let storageToken = dropBoxStorage.Open(dropBoxConfig, accessToken); for folder in dropBoxStorage.GetRoot() do printfn "%s" (folder.Name) dropBoxStorage.Close() 0
Reblogged this on D Says and commented:
great
I can’t create token file. Could you help me? Thanks.
What error do you see?
I used DropBoxTokenIssuer.exe to generate the token file, however, after inputting my login info and allowing the app to access my dropbox, it showed:
The website cannot display the page. HTTP500
Most likely causes:
The website is under maintenance.
The website has a programming error.
This error (HTTP 500 Internal Server Error) means that the website you are visiting had a server problem which prevented the webpage from displaying.”
Could you help me? Thanks in advance.
Sorry, no idea. It seems it does not work for me either.
Having the exact same issue here also
Thanks anyway.
Danny, have got this to work by using the revised Dropbox Token Issuer
https://sharpbox.codeplex.com/workitem/19371
There is no file in the link you gave me. I think it was removed. By the way, I found another token generator file on Codeplex and tried it but it didn’t work too. I think SharpBox was abandoned.
Hi Danny,
Yes the link appears dead i got a copy from a colleague. I can email if your still interested?
It would be great for me if you can send me that copy. Thanks.
How i logout from .NET MVC App ???
When Click on Authorize ” object reference set to an instance of an object ” error box show. Can Any one help ?