private const string AppSecret = "2a3si3j0kvgrush"; // <- not that secret in that case /// <summary> /// Initializes the Dropbox library, and ignites the authorization process if needed. /// </summary> /// <returns>Returns a task to be awaited until the initialization process is done.</returns> public async Task Initialize() { string accessToken; config = ConfigurationUtility.ReadConfigurationFile(GetType()); if (config.TryGetValue("AccessToken", out accessToken) && string.IsNullOrWhiteSpace(accessToken) == false) { accessToken = SecurityUtility.UnprotectString(accessToken, DataProtectionScope.CurrentUser); } if (string.IsNullOrWhiteSpace(accessToken)) { Uri authorizeUri = DropboxOAuth2Helper.GetAuthorizeUri(AppKey, false); var url = authorizeUri.ToString(); MessageBox.Show("After you click the OK button on this dialog, a web page asking you to allow the application will open, and then another one containing a code.\r\n\r\nOnce you see the code, please copy it to the clipboard by selecting it and pressing Ctrl+C, or right click and 'Copy' menu.", "Authorization", MessageBoxButton.OK, MessageBoxImage.Information); Process.Start(url); MessageBox.Show("Please proceed by closing this dialog once you copied the code.", "Authorization", MessageBoxButton.OK, MessageBoxImage.Information); string code = null; try { code = Clipboard.GetText(); } catch (Exception ex) { MessageBox.Show("An error occured:\r\n" + ex.Message, "Authorization Failed", MessageBoxButton.OK, MessageBoxImage.Error); return; } OAuth2Response response = await DropboxOAuth2Helper.ProcessCodeFlowAsync(code, AppKey, AppSecret); accessToken = response.AccessToken; ConfigurationUtility.CreateConfigurationFile(GetType(), new Dictionary <string, string> { { "AccessToken", SecurityUtility.ProtectString(accessToken, DataProtectionScope.CurrentUser) }, }); MessageBox.Show("Authorization process succeeded.", "Authorization", MessageBoxButton.OK, MessageBoxImage.Information); } dropboxClient = new DropboxClient(accessToken); }