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

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

            InitUris();
        }
Beispiel #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);
            }
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
 public Dropbox(OAuthInfo oauth)
 {
     AuthInfo = oauth;
 }
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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));
        }
Beispiel #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);
            }
        }
Beispiel #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);
        }
Beispiel #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);
            }
        }
Beispiel #19
0
 public TwitterTweetForm(OAuthInfo oauth)
     : this()
 {
     AuthInfo = oauth;
 }
 public TwitSnapsUploader(string apiKey, OAuthInfo oauth)
 {
     APIKey = apiKey;
     AuthInfo = oauth;
 }
        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);
            }
        }
        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;
                }
            }
        }
Beispiel #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));
 }
Beispiel #24
0
 public TwitterTweetForm(OAuthInfo oauth, string message)
     : this(oauth)
 {
     Message = message;
 }
 public Dropbox(OAuthInfo oauth, string uploadPath, DropboxAccountInfo accountInfo)
     : this(oauth)
 {
     UploadPath = uploadPath;
     AccountInfo = accountInfo;
 }
Beispiel #26
0
 public Twitter(OAuthInfo oauth)
 {
     AuthInfo = oauth;
 }
Beispiel #27
0
 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);
            }
        }
Beispiel #29
0
 public TwitterMsg(OAuthInfo oauth)
     : this(oauth, "Update Twitter status")
 {
 }
Beispiel #30
0
 protected bool GetAccessToken(string accessTokenURL, OAuthInfo authInfo, HttpMethod httpMethod = HttpMethod.GET)
 {
     return GetAccessTokenEx(accessTokenURL, authInfo, httpMethod) != null;
 }
Beispiel #31
0
 public Imgur_v2(OAuthInfo oauth)
 {
     UploadMethod = AccountType.User;
     AuthInfo = oauth;
 }
Beispiel #32
0
 public Imgur_v2(AccountType uploadMethod, string anonymousKey, OAuthInfo oauth)
 {
     UploadMethod = uploadMethod;
     AnonymousKey = anonymousKey;
     AuthInfo = oauth;
 }
Beispiel #33
0
        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;
        }
 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;
     }
 }
Beispiel #35
0
        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;
        }