Due to the way WP7 doesn’t have any support for synchronous web requests, the response from each Dropbox request comes via an event.

A basic example is logging in to get an OAuth token for a user.


using l3v5y.Dropbox;


// First create a new dropbox client object
WP7Dropbox dropboxClient= new WP7Dropbox(api_key, api_secret);

void GetUserToken(string Username, string Password)
	// Then register for the TokenComplete event
	dropboxClient.TokenComplete += new WP7Dropbox.token_complete(dropboxTokenComplete);
	// Finally, request a token.
	dropboxClient.token(Username, Password);

void dropboxTokenComplete(Token response) 
	// I'd recommend saving the user token, since it should never expire, and it makes it more convenient 
	// The user should be informed of this though 

	IsolatedStorageSettings.ApplicationSettings["Token"] = response; 
	// dropboxClient.user has now been set with the user token, and this will be used in all future calls  
	// WP7Dropbox doesn't cache/store the token in permanent storage (as in, closing and opening will require a new token request
	dropboxClient.TokenComplete -= new WP7Dropbox.token_complete(dropboxTokenComplete); 


If you've stored the user token, then there's no real reason to not use it to log in in the first place


void LogIn()
		Token user = (Token)IsolatedStorageSettings.ApplicationSettings["Token"];
		dropboxClient = new WP7Dropbox(api_key, api_secret, user);
		// Get the username/password


Last edited Sep 2, 2010 at 5:13 PM by l3v5y, version 7


DRCoderz Sep 16, 2011 at 5:32 PM 
the third line on the LogIn method is missing the closing parenthesis - if(IsolatedStorageSettings.ApplicationSettings.Contains("Token"))

bradhuffman Feb 4, 2011 at 2:33 AM 
@miracleman - Go here (https://www.dropbox.com/developers/quickstart), and register as a developer. Once registered, you can create an app. The system will give you a unique api and secret key specific to your app.

miracleman Jan 10, 2011 at 12:05 PM 
What should the api_key and the api_secret contain?