PM> Install-Package DropNetRT
To create an app that uses Dropbox you first need to register your app with Dropbox (Developer site). This will give you the API Key and Secret combination required to use the API.
Once you have your API Key and Secret download DropNetRT from NuGet (or alternatively download the source from GitHub).
To start using DropNetRT create an instance of the DropNetClient class using your API Key and Secret generated from the Dropbox developer site.
The constructor has an overload method for if you have already authenticated with the API and have an access token for the user. (covered in Authentication).
The dropbox API uses oauth for authenticating, it does both v1 and v2 but at the moment DropNetRT only supports oauth v1.
Authentication is a 3 step process.
- Step 1: Get a request token from the API.
- Step 2: Navigate the user to the dropbox site to login (using the request token).
- Step 3: Convert the request token into an access token to use the rest of the API.
Step 1: Get a request token from the API. Call the GetRequestToken function to create a new request token. Note: The DropNetClient instance will save this as the UserLogin property but is also returned by the function.
Step 2: Navigate the user to the dropbox site to login (using the request token).
From here you will need to open a browser with the url given to allow the user to login. Then wait for the callback the the given callback url before moving on. An example of this step can be found in the WP8 sample app (source on github). WinRT apps can use the WebAuthenticationBroker for this, just give it the url and callback parameters then parse the response for the token querystring parameter. (Note the secret doesn't change, only the token)
Step 3: Convert the request token into an access token to use the rest of the API. To do this call the GetAccessToken function. Note: The DropNetClient instance will save this as the UserLogin property but is also returned by the function. Save this token so the user doesn't have to reauthenticate each time.
App folder/Sandbox mode
To set the DropNetClient to use an app folder instead of the users full dropbox folder set the UseSandbox property to true. This may cause the client to throw exceptions if the app is set to only be allowed access to app folders.
Copies a file or folder from one location to another.
Creates an empty folder with the given path
Deletes a file or folder given its path
Gets the Delta (changes) of a given path and cursor from the last time it was called (otherwise returns last 2000 folder changes)
Gets a file from dropbox given the path
Gets info on a file or folder (including folder contents). There are a few functions for getting an items Metadata, most of them are shorthand methods of the main one: GetMetaData(string path, string hash, int? rev, bool list, bool includeDeleted)
Gets a share link for a file or folder.
Searches for a given string.
DropNetRT is a PCL (Portable Class Library) which means the same dll can be used across multiple platforms. Here are the target frameworks:
- .NET 4.5
- .NET for Windows Store apps (WinRT)
- Windows Phone 7.5 and higher
- Silverlight 4 and higher
Checkout the Trello board to whats coming
Apps using DropNetRT
Here is a list of Apps using DropNetRT. If you have an app using it let me know (@dkarzon).
- BoxShot (as of v3.4)