public void GistAuthOpen() { try { OAuth2Info oauth = new OAuth2Info(APIKeys.GitHubID, APIKeys.GitHubSecret); string url = new GitHubGist(oauth).GetAuthorizationURL(); if (!string.IsNullOrEmpty(url)) { Config.GistOAuth2Info = oauth; URLHelpers.OpenURL(url); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void GistAuthComplete(string code) { try { if (!string.IsNullOrEmpty(code) && Config.GistOAuth2Info != null) { bool result = new GitHubGist(Config.GistOAuth2Info).GetAccessToken(code); if (result) { oAuth2Gist.Status = OAuthLoginStatus.LoginSuccessful; MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { oAuth2Gist.Status = OAuthLoginStatus.LoginFailed; MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error); atcGistAccountType.SelectedAccountType = AccountType.Anonymous; } } } catch (Exception ex) { MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } }