public TwitterMsg(OAuthInfo oauth, string title)
 {
     InitializeComponent();
     AuthInfo = oauth;
     Text = title;
     Config = new TwitterClientSettings();
 }
示例#2
0
        public Jira(string jiraHost, OAuthInfo oauth, string jiraIssuePrefix = null)
        {
            _jiraHost = new Uri(jiraHost);
            AuthInfo = oauth;
            _jiraIssuePrefix = jiraIssuePrefix;

            InitUris();
        }
示例#3
0
        public Jira(string jiraBaseAddress, OAuthInfo oauth, string jiraIssuePrefix = null)
        {
            _jiraBaseAddress = jiraBaseAddress;
            AuthInfo = oauth;
            _jiraIssuePrefix = jiraIssuePrefix;

            InitUris();
        }
示例#4
0
 public TwitPicUploader(string key, OAuthInfo oauth)
 {
     APIKey = key;
     AuthInfo = oauth;
     TwitPicUploadType = TwitPicUploadType.UPLOAD_IMAGE_ONLY;
     ShowFull = false;
     TwitPicThumbnailMode = TwitPicThumbnailType.Thumb;
 }
        public DropboxFilesForm(OAuthInfo oauth, string path = null)
        {
            InitializeComponent();
            dropbox = new Dropbox(oauth);
            ilm = new ImageListManager(lvDropboxFiles);

            if (path != null)
            {
                Shown += (sender, e) => OpenDirectory(path);
            }
        }
示例#6
0
        public DropboxFilesForm(OAuthInfo oauth, string path, DropboxAccountInfo accountInfo)
        {
            InitializeComponent();
            Icon = Resources.Dropbox;

            dropbox = new Dropbox(oauth);
            dropboxAccountInfo = accountInfo;
            ilm = new ImageListManager(lvDropboxFiles);

            if (path != null)
            {
                Shown += (sender, e) => OpenDirectory(path);
            }
        }
        public static string GenerateQuery(string url, Dictionary<string, string> args, HttpMethod httpMethod, OAuthInfo oauth)
        {
            if (string.IsNullOrEmpty(oauth.ConsumerKey) || string.IsNullOrEmpty(oauth.ConsumerSecret))
            {
                throw new Exception("ConsumerKey or ConsumerSecret empty.");
            }

            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add(ParameterVersion, oauth.OAuthVersion);
            parameters.Add(ParameterNonce, GenerateNonce());
            parameters.Add(ParameterTimestamp, GenerateTimestamp());
            parameters.Add(ParameterSignatureMethod, HMACSHA1SignatureType);
            parameters.Add(ParameterConsumerKey, oauth.ConsumerKey);

            string secret = null;

            if (!string.IsNullOrEmpty(oauth.UserToken) && !string.IsNullOrEmpty(oauth.UserSecret))
            {
                secret = oauth.UserSecret;
                parameters.Add(ParameterToken, oauth.UserToken);
            }
            else if (!string.IsNullOrEmpty(oauth.AuthToken) && !string.IsNullOrEmpty(oauth.AuthSecret))
            {
                secret = oauth.AuthSecret;
                parameters.Add(ParameterToken, oauth.AuthToken);

                if (!string.IsNullOrEmpty(oauth.AuthVerifier))
                {
                    parameters.Add(ParameterVerifier, oauth.AuthVerifier);
                }
            }

            if (args != null)
            {
                foreach (KeyValuePair<string, string> arg in args)
                {
                    parameters.Add(arg.Key, arg.Value);
                }
            }

            string normalizedUrl = NormalizeUrl(url);
            string normalizedParameters = NormalizeParameters(parameters);
            string signatureBase = GenerateSignatureBase(httpMethod, normalizedUrl, normalizedParameters);
            string signature = GenerateSignature(signatureBase, oauth.ConsumerSecret, secret);

            return string.Format("{0}?{1}&{2}={3}", normalizedUrl, normalizedParameters, ParameterSignature, signature);
        }
示例#8
0
        public static string GetAuthorizationURL(string requestTokenResponse, OAuthInfo oauth, string authorizeURL, string callback = null)
        {
            string url = null;

            NameValueCollection args = HttpUtility.ParseQueryString(requestTokenResponse);

            if (args[ParameterToken] != null)
            {
                oauth.AuthToken = args[ParameterToken];
                url             = string.Format("{0}?{1}={2}", authorizeURL, ParameterToken, oauth.AuthToken);

                if (!string.IsNullOrEmpty(callback))
                {
                    url += string.Format("&{0}={1}", ParameterCallback, Helpers.URLEncode(callback));
                }

                if (args[ParameterTokenSecret] != null)
                {
                    oauth.AuthSecret = args[ParameterTokenSecret];
                }
            }

            return(url);
        }
示例#9
0
        public static string GenerateQuery(string url, Dictionary<string, string> args, HttpMethod httpMethod, OAuthInfo oauth)
        {
            if (string.IsNullOrEmpty(oauth.ConsumerKey)
                || (string.IsNullOrEmpty(oauth.ConsumerSecret) && oauth.SignatureMethod == OAuthInfo.OAuthInfoSignatureMethod.HMAC_SHA1)
                || (oauth.ConsumerPrivateKey == null && oauth.SignatureMethod == OAuthInfo.OAuthInfoSignatureMethod.RSA_SHA1))
            {
                throw new Exception("ConsumerKey or ConsumerSecret or ConsumerPrivateKey empty.");
            }

            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add(ParameterVersion, oauth.OAuthVersion);
            parameters.Add(ParameterNonce, GenerateNonce());
            parameters.Add(ParameterTimestamp, GenerateTimestamp());
            parameters.Add(ParameterConsumerKey, oauth.ConsumerKey);
            switch (oauth.SignatureMethod)
            {
                case OAuthInfo.OAuthInfoSignatureMethod.HMAC_SHA1:
                    parameters.Add(ParameterSignatureMethod, HMACSHA1SignatureType);
                    break;

                case OAuthInfo.OAuthInfoSignatureMethod.RSA_SHA1:
                    parameters.Add(ParameterSignatureMethod, RSASHA1SignatureType);
                    break;

                default:
                    throw new NotImplementedException("Unsupported signature method");
            }

            string secret = null;

            if (!string.IsNullOrEmpty(oauth.UserToken) && !string.IsNullOrEmpty(oauth.UserSecret))
            {
                secret = oauth.UserSecret;
                parameters.Add(ParameterToken, oauth.UserToken);
            }
            else if (!string.IsNullOrEmpty(oauth.AuthToken) && !string.IsNullOrEmpty(oauth.AuthSecret))
            {
                secret = oauth.AuthSecret;
                parameters.Add(ParameterToken, oauth.AuthToken);

                if (!string.IsNullOrEmpty(oauth.AuthVerifier))
                {
                    parameters.Add(ParameterVerifier, oauth.AuthVerifier);
                }
            }

            if (args != null)
            {
                foreach (KeyValuePair<string, string> arg in args)
                {
                    parameters[arg.Key] = arg.Value;
                }
            }

            string normalizedUrl = NormalizeUrl(url);
            string normalizedParameters = NormalizeParameters(parameters);
            string signatureBase = GenerateSignatureBase(httpMethod, normalizedUrl, normalizedParameters);
            byte[] signatureData;
            switch (oauth.SignatureMethod)
            {
                case OAuthInfo.OAuthInfoSignatureMethod.HMAC_SHA1:
                    signatureData = GenerateSignature(signatureBase, oauth.ConsumerSecret, secret);
                    break;
                case OAuthInfo.OAuthInfoSignatureMethod.RSA_SHA1:
                    signatureData = GenerateSignatureRSASHA1(signatureBase, oauth.ConsumerPrivateKey);
                    break;
                default:
                    throw new NotImplementedException("Unsupported signature method");
            }

            string signature = Helpers.URLEncode(Convert.ToBase64String(signatureData));
            return string.Format("{0}?{1}&{2}={3}", normalizedUrl, normalizedParameters, ParameterSignature, signature);
        }
示例#10
0
 public Dropbox(OAuthInfo oauth)
 {
     AuthInfo = oauth;
 }
示例#11
0
        public static string GetAuthorizationURL(string requestTokenResponse, OAuthInfo oauth, string authorizeURL, string callback = null)
        {
            string url = null;

            NameValueCollection args = HttpUtility.ParseQueryString(requestTokenResponse);

            if (args[ParameterToken] != null)
            {
                oauth.AuthToken = args[ParameterToken];
                url = string.Format("{0}?{1}={2}", authorizeURL, ParameterToken, oauth.AuthToken);

                if (!string.IsNullOrEmpty(callback))
                {
                    url += string.Format("&{0}={1}", ParameterCallback, Helpers.URLEncode(callback));
                }

                if (args[ParameterTokenSecret] != null)
                {
                    oauth.AuthSecret = args[ParameterTokenSecret];
                }
            }

            return url;
        }
示例#12
0
        public static NameValueCollection ParseAccessTokenResponse(string accessTokenResponse, OAuthInfo oauth)
        {
            NameValueCollection args = HttpUtility.ParseQueryString(accessTokenResponse);

            if (args != null && args[ParameterToken] != null)
            {
                oauth.UserToken = args[ParameterToken];

                if (args[ParameterTokenSecret] != null)
                {
                    oauth.UserSecret = args[ParameterTokenSecret];

                    return args;
                }
            }

            return null;
        }
示例#13
0
        public static string GenerateQuery(string url, Dictionary <string, string> args, HttpMethod httpMethod, OAuthInfo oauth)
        {
            if (string.IsNullOrEmpty(oauth.ConsumerKey) || string.IsNullOrEmpty(oauth.ConsumerSecret))
            {
                throw new Exception("ConsumerKey or ConsumerSecret empty.");
            }

            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add(ParameterVersion, oauth.OAuthVersion);
            parameters.Add(ParameterNonce, GenerateNonce());
            parameters.Add(ParameterTimestamp, GenerateTimestamp());
            parameters.Add(ParameterSignatureMethod, HMACSHA1SignatureType);
            parameters.Add(ParameterConsumerKey, oauth.ConsumerKey);

            string secret = null;

            if (!string.IsNullOrEmpty(oauth.UserToken) && !string.IsNullOrEmpty(oauth.UserSecret))
            {
                secret = oauth.UserSecret;
                parameters.Add(ParameterToken, oauth.UserToken);
            }
            else if (!string.IsNullOrEmpty(oauth.AuthToken) && !string.IsNullOrEmpty(oauth.AuthSecret))
            {
                secret = oauth.AuthSecret;
                parameters.Add(ParameterToken, oauth.AuthToken);

                if (!string.IsNullOrEmpty(oauth.AuthVerifier))
                {
                    parameters.Add(ParameterVerifier, oauth.AuthVerifier);
                }
            }

            if (args != null)
            {
                foreach (KeyValuePair <string, string> arg in args)
                {
                    parameters.Add(arg.Key, arg.Value);
                }
            }

            string normalizedUrl        = NormalizeUrl(url);
            string normalizedParameters = NormalizeParameters(parameters);
            string signatureBase        = GenerateSignatureBase(httpMethod, normalizedUrl, normalizedParameters);
            string signature            = GenerateSignature(signatureBase, oauth.ConsumerSecret, secret);

            return(string.Format("{0}?{1}&{2}={3}", normalizedUrl, normalizedParameters, ParameterSignature, signature));
        }
示例#14
0
        public static string GenerateQuery(string url, Dictionary <string, string> args, HttpMethod httpMethod, OAuthInfo oauth)
        {
            if (string.IsNullOrEmpty(oauth.ConsumerKey) ||
                (string.IsNullOrEmpty(oauth.ConsumerSecret) && oauth.SignatureMethod == OAuthInfo.OAuthInfoSignatureMethod.HMAC_SHA1) ||
                (oauth.ConsumerPrivateKey == null && oauth.SignatureMethod == OAuthInfo.OAuthInfoSignatureMethod.RSA_SHA1))
            {
                throw new Exception("ConsumerKey or ConsumerSecret or ConsumerPrivateKey empty.");
            }

            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add(ParameterVersion, oauth.OAuthVersion);
            parameters.Add(ParameterNonce, GenerateNonce());
            parameters.Add(ParameterTimestamp, GenerateTimestamp());
            parameters.Add(ParameterConsumerKey, oauth.ConsumerKey);
            switch (oauth.SignatureMethod)
            {
            case OAuthInfo.OAuthInfoSignatureMethod.HMAC_SHA1:
                parameters.Add(ParameterSignatureMethod, HMACSHA1SignatureType);
                break;

            case OAuthInfo.OAuthInfoSignatureMethod.RSA_SHA1:
                parameters.Add(ParameterSignatureMethod, RSASHA1SignatureType);
                break;

            default:
                throw new NotImplementedException("Unsupported signature method");
            }

            string secret = null;

            if (!string.IsNullOrEmpty(oauth.UserToken) && !string.IsNullOrEmpty(oauth.UserSecret))
            {
                secret = oauth.UserSecret;
                parameters.Add(ParameterToken, oauth.UserToken);
            }
            else if (!string.IsNullOrEmpty(oauth.AuthToken) && !string.IsNullOrEmpty(oauth.AuthSecret))
            {
                secret = oauth.AuthSecret;
                parameters.Add(ParameterToken, oauth.AuthToken);

                if (!string.IsNullOrEmpty(oauth.AuthVerifier))
                {
                    parameters.Add(ParameterVerifier, oauth.AuthVerifier);
                }
            }

            if (args != null)
            {
                foreach (KeyValuePair <string, string> arg in args)
                {
                    parameters[arg.Key] = arg.Value;
                }
            }

            string normalizedUrl        = NormalizeUrl(url);
            string normalizedParameters = NormalizeParameters(parameters);
            string signatureBase        = GenerateSignatureBase(httpMethod, normalizedUrl, normalizedParameters);

            byte[] signatureData;
            switch (oauth.SignatureMethod)
            {
            case OAuthInfo.OAuthInfoSignatureMethod.HMAC_SHA1:
                signatureData = GenerateSignature(signatureBase, oauth.ConsumerSecret, secret);
                break;

            case OAuthInfo.OAuthInfoSignatureMethod.RSA_SHA1:
                signatureData = GenerateSignatureRSASHA1(signatureBase, oauth.ConsumerPrivateKey);
                break;

            default:
                throw new NotImplementedException("Unsupported signature method");
            }

            string signature = Helpers.URLEncode(Convert.ToBase64String(signatureData));

            return(string.Format("{0}?{1}&{2}={3}", normalizedUrl, normalizedParameters, ParameterSignature, signature));
        }
        public void JiraAuthOpen()
        {
            try
            {
                OAuthInfo oauth = new OAuthInfo(APIKeys.JiraConsumerKey);
                oauth.SignatureMethod = OAuthInfo.OAuthInfoSignatureMethod.RSA_SHA1;
                oauth.ConsumerPrivateKey = Jira.PrivateKey;

                string url = new Jira(Config.JiraHost, oauth).GetAuthorizationURL();

                if (!string.IsNullOrEmpty(url))
                {
                    Config.JiraOAuthInfo = oauth;
                    Helpers.OpenURL(url);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#16
0
        public static NameValueCollection ParseAccessTokenResponse(string accessTokenResponse, OAuthInfo oauth)
        {
            NameValueCollection args = HttpUtility.ParseQueryString(accessTokenResponse);

            if (args != null && args[ParameterToken] != null)
            {
                oauth.UserToken = args[ParameterToken];

                if (args[ParameterTokenSecret] != null)
                {
                    oauth.UserSecret = args[ParameterTokenSecret];

                    return(args);
                }
            }

            return(null);
        }
示例#17
0
 private void TwitterAccountAddButton_Click(object sender, EventArgs e)
 {
     OAuthInfo acc = new OAuthInfo();
     Config.TwitterOAuthInfoList.Add(acc);
     ucTwitterAccounts.AddItem(acc);
 }
        public void PhotobucketAuthOpen()
        {
            try
            {
                OAuthInfo oauth = new OAuthInfo(APIKeys.PhotobucketConsumerKey, APIKeys.PhotobucketConsumerSecret);

                string url = new Photobucket(oauth).GetAuthorizationURL();

                if (!string.IsNullOrEmpty(url))
                {
                    Config.PhotobucketOAuthInfo = oauth;
                    Helpers.OpenURL(url);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#19
0
 public TwitterTweetForm(OAuthInfo oauth)
     : this()
 {
     AuthInfo = oauth;
 }
 public TwitSnapsUploader(string apiKey, OAuthInfo oauth)
 {
     APIKey = apiKey;
     AuthInfo = oauth;
 }
示例#21
0
        public void CopyAuthOpen()
        {
            try
            {
                OAuthInfo oauth = new OAuthInfo(APIKeys.CopyConsumerKey, APIKeys.CopyConsumerSecret);

                string url = new Copy(oauth).GetAuthorizationURL();

                if (!string.IsNullOrEmpty(url))
                {
                    Config.CopyOAuthInfo = oauth;
                    URLHelpers.OpenURL(url);
                    DebugHelper.WriteLine("CopyAuthOpen - Authorization URL is opened: " + url);
                }
                else
                {
                    DebugHelper.WriteLine("CopyAuthOpen - Authorization URL is empty.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#22
0
        public void TwitterAuthOpen()
        {
            if (CheckTwitterAccounts())
            {
                OAuthInfo acc = new OAuthInfo(APIKeys.TwitterConsumerKey, APIKeys.TwitterConsumerSecret);
                Twitter twitter = new Twitter(acc);
                string url = twitter.GetAuthorizationURL();

                if (!string.IsNullOrEmpty(url))
                {
                    acc.Description = Config.TwitterOAuthInfoList[Config.TwitterSelectedAccount].Description;
                    Config.TwitterOAuthInfoList[Config.TwitterSelectedAccount] = acc;
                    ucTwitterAccounts.pgSettings.SelectedObject = acc;
                    URLHelpers.OpenURL(url);
                    btnTwitterLogin.Enabled = true;
                }
            }
        }
示例#23
0
 public static bool CheckOAuth(OAuthInfo oauth)
 {
     return(oauth != null && !string.IsNullOrEmpty(oauth.ConsumerKey) && !string.IsNullOrEmpty(oauth.ConsumerSecret) &&
            !string.IsNullOrEmpty(oauth.UserToken) && !string.IsNullOrEmpty(oauth.UserSecret));
 }
示例#24
0
 public TwitterTweetForm(OAuthInfo oauth, string message)
     : this(oauth)
 {
     Message = message;
 }
示例#25
0
 public Dropbox(OAuthInfo oauth, string uploadPath, DropboxAccountInfo accountInfo)
     : this(oauth)
 {
     UploadPath = uploadPath;
     AccountInfo = accountInfo;
 }
示例#26
0
 public Twitter(OAuthInfo oauth)
 {
     AuthInfo = oauth;
 }
示例#27
0
文件: Minus.cs 项目: TreeSeed/ShareX
 public Minus(MinusOptions config, OAuthInfo auth)
 {
     Config = config;
     AuthInfo = auth;
 }
        public void DropboxAuthOpen()
        {
            try
            {
                OAuthInfo oauth = new OAuthInfo(APIKeys.DropboxConsumerKey, APIKeys.DropboxConsumerSecret);

                string url = new Dropbox(oauth).GetAuthorizationURL();

                if (!string.IsNullOrEmpty(url))
                {
                    Config.DropboxOAuthInfo = oauth;
                    Helpers.OpenURL(url);
                    btnDropboxCompleteAuth.Enabled = true;
                    DebugHelper.WriteLine("DropboxAuthOpen - Authorization URL is opened: " + url);
                }
                else
                {
                    DebugHelper.WriteLine("DropboxAuthOpen - Authorization URL is empty.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#29
0
 public TwitterMsg(OAuthInfo oauth)
     : this(oauth, "Update Twitter status")
 {
 }
示例#30
0
文件: Uploader.cs 项目: Z1ni/ShareX
 protected bool GetAccessToken(string accessTokenURL, OAuthInfo authInfo, HttpMethod httpMethod = HttpMethod.GET)
 {
     return GetAccessTokenEx(accessTokenURL, authInfo, httpMethod) != null;
 }
示例#31
0
文件: Imgur_v2.cs 项目: Z1ni/ShareX
 public Imgur_v2(OAuthInfo oauth)
 {
     UploadMethod = AccountType.User;
     AuthInfo = oauth;
 }
示例#32
0
文件: Imgur_v2.cs 项目: Z1ni/ShareX
 public Imgur_v2(AccountType uploadMethod, string anonymousKey, OAuthInfo oauth)
 {
     UploadMethod = uploadMethod;
     AnonymousKey = anonymousKey;
     AuthInfo = oauth;
 }
示例#33
0
文件: Uploader.cs 项目: Z1ni/ShareX
        protected NameValueCollection GetAccessTokenEx(string accessTokenURL, OAuthInfo authInfo, HttpMethod httpMethod = HttpMethod.GET)
        {
            if (string.IsNullOrEmpty(authInfo.AuthToken) || string.IsNullOrEmpty(authInfo.AuthSecret))
            {
                throw new Exception("Auth infos missing. Open Authorization URL first.");
            }

            string url = OAuthManager.GenerateQuery(accessTokenURL, null, httpMethod, authInfo);

            string response = SendRequest(httpMethod, url);

            if (!string.IsNullOrEmpty(response))
            {
                return OAuthManager.ParseAccessTokenResponse(response, authInfo);
            }

            return null;
        }
示例#34
0
 private void TwitterAccountAddButton_Click(object sender, EventArgs e)
 {
     OAuthInfo acc = new OAuthInfo(APIKeys.TwitterConsumerKey, APIKeys.TwitterConsumerSecret);
     Config.TwitterOAuthInfoList.Add(acc);
     ucTwitterAccounts.AccountsList.Items.Add(acc);
     ucTwitterAccounts.AccountsList.SelectedIndex = ucTwitterAccounts.AccountsList.Items.Count - 1;
     if (CheckTwitterAccounts())
     {
         ucTwitterAccounts.SettingsGrid.SelectedObject = acc;
     }
 }
示例#35
0
文件: Uploader.cs 项目: Z1ni/ShareX
        protected string GetAuthorizationURL(string requestTokenURL, string authorizeURL, OAuthInfo authInfo,
            Dictionary<string, string> customParameters = null, HttpMethod httpMethod = HttpMethod.GET)
        {
            string url = OAuthManager.GenerateQuery(requestTokenURL, customParameters, httpMethod, authInfo);

            string response = SendRequest(httpMethod, url);

            if (!string.IsNullOrEmpty(response))
            {
                return OAuthManager.GetAuthorizationURL(response, authInfo, authorizeURL);
            }

            return null;
        }