Ejemplo n.º 1
0
        private WebConsumer CreateConsumer()
        {
            String authHandler    = authHandleTextBox.Text;
            string consumerKey    = consumerKeyTextBox.Text;
            string consumerSecret = consumerSecretTextBox.Text;

            Session["authHandler"] = authHandler;

            var tokenManager = Session["WcfTokenManager"] as InMemoryTokenManager;

            if (tokenManager == null)
            {
                tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret);
                Session["WcfTokenManager"] = tokenManager;
            }
            MessageReceivingEndpoint oauthEndpoint = new MessageReceivingEndpoint(
                new Uri(authHandler),
                HttpDeliveryMethods.PostRequest);
            WebConsumer consumer = new WebConsumer(
                new ServiceProviderDescription
            {
                RequestTokenEndpoint      = oauthEndpoint,
                UserAuthorizationEndpoint = oauthEndpoint,
                AccessTokenEndpoint       = oauthEndpoint,
                TamperProtectionElements  = new DotNetOpenAuth.Messaging.ITamperProtectionChannelBindingElement[] {
                    new HmacSha1SigningBindingElement(),
                },
            },
                tokenManager);

            return(consumer);
        }
Ejemplo n.º 2
0
        private WebConsumer CreateConsumer()
        {
            String authHandler = authHandleTextBox.Text;
            string consumerKey = consumerKeyTextBox.Text;
            string consumerSecret = consumerSecretTextBox.Text;

            Session["authHandler"] = authHandler;

            var tokenManager = Session["WcfTokenManager"] as InMemoryTokenManager;
            if (tokenManager == null)
            {
                tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret);
                Session["WcfTokenManager"] = tokenManager;
            }
            MessageReceivingEndpoint oauthEndpoint = new MessageReceivingEndpoint(
                new Uri(authHandler),
                HttpDeliveryMethods.PostRequest);
            WebConsumer consumer = new WebConsumer(
                new ServiceProviderDescription
                {
                    RequestTokenEndpoint = oauthEndpoint,
                    UserAuthorizationEndpoint = oauthEndpoint,
                    AccessTokenEndpoint = oauthEndpoint,
                    TamperProtectionElements = new DotNetOpenAuth.Messaging.ITamperProtectionChannelBindingElement[] {
                    new HmacSha1SigningBindingElement(),
                },
                },
                tokenManager);

            return consumer;
        }