public void DropboxAuthComplete() { try { if (Config.DropboxOAuthInfo != null && !string.IsNullOrEmpty(Config.DropboxOAuthInfo.AuthToken) && !string.IsNullOrEmpty(Config.DropboxOAuthInfo.AuthSecret)) { Dropbox dropbox = new Dropbox(Config.DropboxOAuthInfo); bool result = dropbox.GetAccessToken(); if (result) { DropboxAccountInfo account = dropbox.GetAccountInfo(); if (account != null) { Config.DropboxAccountInfo = account; Config.DropboxUploadPath = txtDropboxPath.Text; UpdateDropboxStatus(); MessageBox.Show("Login successful.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } MessageBox.Show("GetAccountInfo failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Login failed.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("You must give access from Authorize page first.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Config.DropboxOAuthInfo = null; UpdateDropboxStatus(); } catch (Exception ex) { DebugHelper.WriteException(ex); MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void DropboxAuthComplete(string code) { try { if (!string.IsNullOrEmpty(code) && Config.DropboxOAuth2Info != null) { Dropbox dropbox = new Dropbox(Config.DropboxOAuth2Info); bool result = dropbox.GetAccessToken(code); if (result) { Config.DropboxAccountInfo = dropbox.GetAccountInfo(); UpdateDropboxStatus(); oauth2Dropbox.Status = OAuthLoginStatus.LoginSuccessful; if (Config.DropboxAccountInfo != null) { MessageBox.Show("Login successful.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Login successful but GetAccountInfo failed.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } return; } else { oauth2Dropbox.Status = OAuthLoginStatus.LoginFailed; MessageBox.Show("Login failed.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } } Config.DropboxAccountInfo = null; UpdateDropboxStatus(); } catch (Exception ex) { DebugHelper.WriteException(ex); MessageBox.Show(ex.ToString(), Application.ProductName + " - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }