I am currently looking into adding dropbox to my c# software. I am using spring.social
from https://github.com/SpringSource/spring-net-social-dropbox.
I have the following code to do the authentication
private void authenticateDropbox()
{
try
{
DropboxServiceProvider dropboxServiceProvider = new DropboxServiceProvider(dropboxAppKey, dropboxAppSecret, AccessLevel.AppFolder);
//lblStatus.Content = "Getting request Token";
OAuthToken oauthToken = dropboxServiceProvider.OAuthOperations.FetchRequestTokenAsync(null, null).Result;
//lblStatus.Content = "Request token retrieved";
OAuth1Parameters parameters = new OAuth1Parameters();
string authenticateUrl = dropboxServiceProvider.OAuthOperations.BuildAuthorizeUrl(oauthToken.Value, parameters);
//lblStatus.Content = "Redirecting user for authentication";
Process.Start(authenticateUrl);
}
catch (AggregateException ex)
{
MessageBox.Show("AggregateException: Failed to authenticate\n\n" + ex.Message, "Authentication Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
catch (Exception ex)
{
MessageBox.Show("General Exception: Failed to authenticate\n\n" + ex.Message, "Authentication Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
I am successfully loading my default browser and I can allow the app and I get the success page. In the same after it has done the Process.start()
method it asks the user to press enter to continue after the success page has been shown, however, I am doing it in a wpf application and I don't really want to have to ask the user to press a button to make my program continue after authorisation from the browser.
I saw in the FetchRequestTokenAsync
function there is a callback parameter but I am not sure how to do this or even if this is what I want.
Basically what I want is when the browser says that authorisation was successful it closes the browser and C# picks up that it was successfully authorised and then continues.
Thanks for any help you can provide.