PM> Install-Package DropNetRT
Getting started
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).
DropNetClient
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).
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.
User functions
coming soon
File functions
Copy
Copies a file or folder from one location to another.
Create Folder
Creates an empty folder with the given path
Delete
Deletes a file or folder given its path
Get Delta
Gets the Delta (changes) of a given path and cursor from the last time it was called (otherwise returns last 2000 folder changes)
Get File
Gets a file from dropbox given the path
GetMetaData
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)
GetShare
Gets a share link for a file or folder.
Search
Searches for a given string.
Platform support
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
Samples
coming soon
Upcoming features
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)