Ejemplo n.º 1
0
        // Get the request token and verifier.
        private void button1_Click(object sender, EventArgs e)
        {
            Chilkat.OAuth1 oauth = new Chilkat.OAuth1();

            oauth.GenNonce(16);
            oauth.GenTimestamp();

            // The 1st step is to get a request token by sending an HTTP GET like this:
            oauth.OauthVersion    = "1.0";
            oauth.OauthMethod     = "GET";
            oauth.OauthUrl        = "https://api.login.yahoo.com/oauth/v2/get_request_token";
            oauth.ConsumerKey     = ConsumerKey;
            oauth.ConsumerSecret  = ConsumerSecret;
            oauth.SignatureMethod = "HMAC-SHA1";
            oauth.AddParam("oauth_callback", "oob");

            // Generate the OAuth1 signature and URL.
            bool success = oauth.Generate();

            if (success != true)
            {
                textBox1.Text = oauth.LastErrorText;
                return;
            }

            // Properties set by the Generate method:
            //textBox1.Text = "BaseString: " + oauth.BaseString + "\r\n" +
            //    "EncodedSignature : " + oauth.EncodedSignature + "\r\n" +
            //    "HmacKey : " + oauth.HmacKey + "\r\n" +
            //    "GeneratedUrl : " + oauth.GeneratedUrl + "\r\n" +
            //    "QueryString : " + oauth.QueryString + "\r\n" +
            //    "Signature  : " + oauth.Signature + "\r\n" +
            //    "AuthorizationHeader  : " + oauth.AuthorizationHeader + "\r\n"
            //    ;

            string requestTokenUrl = oauth.GeneratedUrl + "&oauth_signature=" + oauth.EncodedSignature;

            Chilkat.Http http = new Chilkat.Http();

            // Get the request token...
            Chilkat.HttpResponse resp = http.QuickGetObj(requestTokenUrl);
            if (resp == null)
            {
                textBox1.Text = http.LastErrorText;
                return;
            }

            // Get User Authorization -- get a request verifier interactively via the embedded web browser:
            string encodedResponseParams = resp.BodyStr;

            OAuthToken       = resp.UrlEncParamValue(encodedResponseParams, "oauth_token");
            OAuthTokenSecret = resp.UrlEncParamValue(encodedResponseParams, "oauth_token_secret");
            string userAuthUrl = "https://api.login.yahoo.com/oauth/v2/request_auth?oauth_token=" + OAuthToken;

            webBrowser1.Navigate(userAuthUrl);

            return;
        }
Ejemplo n.º 2
0
        // Get the request token and verifier.
        private void button1_Click(object sender, EventArgs e)
        {
            Chilkat.OAuth1 oauth = new Chilkat.OAuth1();

            oauth.GenNonce(16);
            oauth.GenTimestamp();

            // The 1st step is to get a request token by sending an HTTP GET like this:
            oauth.OauthVersion = "1.0";
            oauth.OauthMethod = "GET";
            oauth.OauthUrl = "https://api.login.yahoo.com/oauth/v2/get_request_token";
            oauth.ConsumerKey = ConsumerKey;
            oauth.ConsumerSecret = ConsumerSecret;
            oauth.SignatureMethod = "HMAC-SHA1";
            oauth.AddParam("oauth_callback", "oob");

            // Generate the OAuth1 signature and URL.
            bool success = oauth.Generate();
            if (success != true) {
            textBox1.Text = oauth.LastErrorText;
            return;
            }

            // Properties set by the Generate method:
            //textBox1.Text = "BaseString: " + oauth.BaseString + "\r\n" +
            //    "EncodedSignature : " + oauth.EncodedSignature + "\r\n" +
            //    "HmacKey : " + oauth.HmacKey + "\r\n" +
            //    "GeneratedUrl : " + oauth.GeneratedUrl + "\r\n" +
            //    "QueryString : " + oauth.QueryString + "\r\n" +
            //    "Signature  : " + oauth.Signature + "\r\n" +
            //    "AuthorizationHeader  : " + oauth.AuthorizationHeader + "\r\n"
            //    ;

            string requestTokenUrl = oauth.GeneratedUrl + "&oauth_signature=" + oauth.EncodedSignature;

            Chilkat.Http http = new Chilkat.Http();

            // Get the request token...
            Chilkat.HttpResponse resp = http.QuickGetObj(requestTokenUrl);
            if (resp == null) {
            textBox1.Text = http.LastErrorText;
            return;
            }

            // Get User Authorization -- get a request verifier interactively via the embedded web browser:
            string encodedResponseParams = resp.BodyStr;
            OAuthToken = resp.UrlEncParamValue(encodedResponseParams, "oauth_token");
            OAuthTokenSecret = resp.UrlEncParamValue(encodedResponseParams, "oauth_token_secret");
            string userAuthUrl = "https://api.login.yahoo.com/oauth/v2/request_auth?oauth_token=" + OAuthToken;

            webBrowser1.Navigate(userAuthUrl);

            return;
        }
Ejemplo n.º 3
0
        // Exchange the Request Token and OAuth Verifier for an Access Token
        private void button2_Click(object sender, EventArgs e)
        {
            Chilkat.OAuth1 oauth = new Chilkat.OAuth1();

            oauth.GenNonce(16);
            oauth.GenTimestamp();

            // The 1st step is to get a request token by sending an HTTP GET like this:
            oauth.OauthVersion    = "1.0";
            oauth.OauthMethod     = "GET";
            oauth.OauthUrl        = "https://api.login.yahoo.com/oauth/v2/get_token";
            oauth.ConsumerKey     = ConsumerKey;
            oauth.ConsumerSecret  = ConsumerSecret;
            oauth.Token           = OAuthToken;
            oauth.TokenSecret     = OAuthTokenSecret;
            oauth.SignatureMethod = "HMAC-SHA1";
            oauth.AddParam("oauth_verifier", txtVerifier.Text);

            // Generate the OAuth1 signature and URL.
            bool success = oauth.Generate();

            if (success != true)
            {
                textBox1.Text = oauth.LastErrorText;
                return;
            }

            string getAccessTokenUrl = oauth.GeneratedUrl + "&oauth_signature=" + oauth.EncodedSignature;

            Chilkat.Http http = new Chilkat.Http();

            // Get the request token...
            Chilkat.HttpResponse resp = http.QuickGetObj(getAccessTokenUrl);
            if (resp == null)
            {
                textBox1.Text = http.LastErrorText;
                return;
            }

            // Get the access token.
            string encodedResponseParams = resp.BodyStr;

            OAuthAccessToken       = resp.UrlEncParamValue(encodedResponseParams, "oauth_token");
            OAuthAccessTokenSecret = resp.UrlEncParamValue(encodedResponseParams, "oauth_token_secret");

            textBox1.Text = "success!\n";

            return;
        }
Ejemplo n.º 4
0
        // Exchange the Request Token and OAuth Verifier for an Access Token
        private void button2_Click(object sender, EventArgs e)
        {
            Chilkat.OAuth1 oauth = new Chilkat.OAuth1();

            oauth.GenNonce(16);
            oauth.GenTimestamp();

            // The 1st step is to get a request token by sending an HTTP GET like this:
            oauth.OauthVersion = "1.0";
            oauth.OauthMethod = "GET";
            oauth.OauthUrl = "https://api.login.yahoo.com/oauth/v2/get_token";
            oauth.ConsumerKey = ConsumerKey;
            oauth.ConsumerSecret = ConsumerSecret;
            oauth.Token = OAuthToken;
            oauth.TokenSecret = OAuthTokenSecret;
            oauth.SignatureMethod = "HMAC-SHA1";
            oauth.AddParam("oauth_verifier", txtVerifier.Text);

            // Generate the OAuth1 signature and URL.
            bool success = oauth.Generate();
            if (success != true)
            {
            textBox1.Text = oauth.LastErrorText;
            return;
            }

            string getAccessTokenUrl = oauth.GeneratedUrl + "&oauth_signature=" + oauth.EncodedSignature;

            Chilkat.Http http = new Chilkat.Http();

            // Get the request token...
            Chilkat.HttpResponse resp = http.QuickGetObj(getAccessTokenUrl);
            if (resp == null)
            {
            textBox1.Text = http.LastErrorText;
            return;
            }

            // Get the access token.
            string encodedResponseParams = resp.BodyStr;
            OAuthAccessToken = resp.UrlEncParamValue(encodedResponseParams, "oauth_token");
            OAuthAccessTokenSecret = resp.UrlEncParamValue(encodedResponseParams, "oauth_token_secret");

            textBox1.Text = "success!\n";

            return;
        }