Exemplo n.º 1
0
    internal static OAuthWebQuery RefreshAccessTokenQuery()
    {
        var oauth = new OAuthWorkflow
        {
            AccessTokenUrl = AppSettings.AccessTokenUri,
            ConsumerKey = AppSettings.consumerKey,
            ConsumerSecret = AppSettings.consumerKeySecret,
            ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
            SignatureMethod = OAuthSignatureMethod.HmacSha1,
            Token = MainUtil.GetKeyValue<string>("AccessToken"),
            TokenSecret = MainUtil.GetKeyValue<string>("AccessTokenSecret"),
            SessionHandle = MainUtil.GetKeyValue<string>("SessionHandle"),
            Version = AppSettings.oAuthVersion //
        };

        var info = oauth.BuildAccessTokenInfo(WebMethod.Post);

        ////replace signature
        //info.Signature = AppSettings.consumerKeySecret + "&" + oauth.TokenSecret;
        //info.Signature = HttpUtility.UrlEncode(info.Signature);
        ////replace signature

        info.Token = HttpUtility.UrlEncode(info.Token);
    
        var sessionParameter = new WebPair("oauth_session_handle", MainUtil.GetKeyValue<string>("SessionHandle"));
        var objOAuthWebQuery = new OAuthWebQuery(info, false);
        objOAuthWebQuery.HasElevatedPermissions = true;
        objOAuthWebQuery.SilverlightUserAgentHeader = "Hammock";
        objOAuthWebQuery.Parameters.Add(sessionParameter);
        return objOAuthWebQuery;
    }
Exemplo n.º 2
0
    internal static OAuthWebQuery GetAccessTokenQuery(string requestToken, string RequestTokenSecret, string oAuthVerificationPin)
    {
        var oauth = new OAuthWorkflow
        {
            AccessTokenUrl = AppSettings.AccessTokenUri,
            ConsumerKey = AppSettings.consumerKey,
            ConsumerSecret = AppSettings.consumerKeySecret,
            ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
            SignatureMethod = OAuthSignatureMethod.HmacSha1,
            Token = HttpUtility.UrlEncode(requestToken),
            TokenSecret = RequestTokenSecret,
            Verifier = oAuthVerificationPin,
            Version = AppSettings.oAuthVersion //
        };

        var info = oauth.BuildAccessTokenInfo(WebMethod.Post);
     
        ////replace signature
        //info.Signature = AppSettings.consumerKeySecret + "&" + oauth.TokenSecret;
        //info.Signature = HttpUtility.UrlEncode(info.Signature);
        ////replace signature
        
        var objOAuthWebQuery = new OAuthWebQuery(info, false);
        objOAuthWebQuery.HasElevatedPermissions = true;
        objOAuthWebQuery.SilverlightUserAgentHeader = "Hammock";
        return objOAuthWebQuery;
    }
Exemplo n.º 3
0
        internal static OAuthWebQuery GetRequestTokenQuery()
        {
            var oauth = new OAuthWorkflow
            {
                ConsumerKey = AppSettings.consumerKey,
                ConsumerSecret = AppSettings.consumerKeySecret,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
                RequestTokenUrl = AppSettings.RequestTokenUri,
                Version = AppSettings.oAuthVersion,
                CallbackUrl = AppSettings.CallbackUri
            };

            var info = oauth.BuildRequestTokenInfo(WebMethod.Get);
            var objOAuthWebQuery = new OAuthWebQuery(info, false);
            objOAuthWebQuery.HasElevatedPermissions = true;
            objOAuthWebQuery.SilverlightUserAgentHeader = "Hammock";
            return objOAuthWebQuery;
        }
Exemplo n.º 4
0
        //internal static OAuthWebQuery GetAccessTokenQuery(string requestToken, string RequestTokenSecret, string oAuthVerificationPin)
        internal static OAuthWebQuery GetAccessTokenQuery(string requestToken, string RequestTokenSecret)
        {
            var oauth = new OAuthWorkflow
           {
               AccessTokenUrl = DailyBurnSettings.AccessTokenUri,
               ConsumerKey = DailyBurnSettings.consumerKey,
               ConsumerSecret = DailyBurnSettings.consumerKeySecret,
               ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
               SignatureMethod = OAuthSignatureMethod.HmacSha1,
               Token = requestToken,
               Version = DailyBurnSettings.oAuthVersion
           };

            var info = oauth.BuildAccessTokenInfo(WebMethod.Get);
            var objOAuthWebQuery = new OAuthWebQuery(info);
            objOAuthWebQuery.HasElevatedPermissions = true;
            objOAuthWebQuery.SilverlightUserAgentHeader = "Hammock";
            objOAuthWebQuery.SilverlightMethodHeader = "GET";
            return objOAuthWebQuery;
        }
Exemplo n.º 5
0
        internal static OAuthWebQuery GetAccessTokenQuery(string requestToken, string RequestTokenSecret, string oAuthVerificationPin)
        {
            var oauth = new OAuthWorkflow
            {
                AccessTokenUrl = AppSettings.TwitterAccessTokenUri,
                ConsumerKey = AppSettings.TwitterConsumerKey,
                ConsumerSecret = AppSettings.TwitterConsumerKeySecret,
                ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                Token = requestToken,
                Verifier = oAuthVerificationPin,
                Version = AppSettings.TwitterOAuthVersion
            };

            var info = oauth.BuildAccessTokenInfo(WebMethod.Post);
            var objOAuthWebQuery = new OAuthWebQuery(info, AppSettings.InDebug);
            objOAuthWebQuery.HasElevatedPermissions = true;
            objOAuthWebQuery.SilverlightUserAgentHeader = "Hammock";
            objOAuthWebQuery.Method = WebMethod.Get;
            //objOAuthWebQuery.SilverlightMethodHeader = "GET";
            return objOAuthWebQuery;
        }
Exemplo n.º 6
0
        public static void Authenticate(WebBrowser wb)
        {
            m_browser = wb;
            var oauth = new OAuthWorkflow
            {
                ConsumerKey = TwitterSettings.ConsumerKey,
                ConsumerSecret = TwitterSettings.ConsumerKeySecret,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
                RequestTokenUrl = TwitterSettings.RequestTokenUri,
                Version = TwitterSettings.OAuthVersion,
                CallbackUrl = TwitterSettings.CallbackUri
            };

            var info = oauth.BuildRequestTokenInfo(WebMethod.Get);
            var objOAuthWebQuery = new OAuthWebQuery(info);
            objOAuthWebQuery.HasElevatedPermissions = true;
            objOAuthWebQuery.SilverlightUserAgentHeader = "Hammock";
            objOAuthWebQuery.SilverlightMethodHeader = "GET";

            objOAuthWebQuery.QueryResponse += new EventHandler<WebQueryResponseEventArgs>(objOAuthWebQuery_QueryResponse);
            objOAuthWebQuery.RequestAsync(TwitterSettings.RequestTokenUri, null);
            
        }
        private void loginBrowserControl_Navigating(object sender, NavigatingEventArgs e)
        {
            if (e.Uri.ToString().StartsWith(AppSettings.CallbackUri))
            {
                var AuthorizeResult = MainUtil.GetQueryParameters(e.Uri.ToString());
                var VerifyPin = AuthorizeResult["oauth_verifier"];
                this.loginBrowserControl.Visibility = Visibility.Collapsed;
                AccessTokenQuery = OAuthUtil.GetAccessTokenQuery(OAuthTokenKey, tokenSecret, VerifyPin);
                AccessTokenQuery.QueryResponse += new EventHandler<WebQueryResponseEventArgs>(AccessTokenQuery_QueryResponse);
                AccessTokenQuery.RequestAsync(AppSettings.AccessTokenUri, null);

            }
        }