getAccessToken() 공개 메소드

public getAccessToken ( string oauth_verifier ) : string
oauth_verifier string
리턴 string
예제 #1
0
파일: Main.cs 프로젝트: possan/sharpOAuth
        /// <summary>
        /// With this test, the application will request an oauth_access token for the current user. The user will have to authorize the app (this code sample) to access his twitter account.
        /// A combination of keys will be generated for him : an oauth access token.
        /// </summary>
        public void test_twitterOauthClient()
        {
            // Create an OAuth config
            OAuthConfig oauthConfig = new OAuthConfig("console");
            oauthConfig.SiteUrl = "http://www.worldgoneweb.com";
            oauthConfig.OauthVersion = "1.0";
            oauthConfig.OauthSignatureMethod = "HMAC-SHA1";
            oauthConfig.ConsumerKey = TwitterOAuthTest._consumerKey;
            oauthConfig.ConsumerSecret = TwitterOAuthTest._consumerSecret;
            oauthConfig.RequestTokenUrl = "https://api.twitter.com/oauth/request_token";
            oauthConfig.AccessTokenUrl = "https://api.twitter.com/oauth/access_token";
            oauthConfig.UserAuthorizationUrl = "https://api.twitter.com/oauth/authorize";

            // Create an OAuth consumer
            OAuthConsumer oauthConsumer = new OAuthConsumer(oauthConfig, "console");

            // Request Token
            oauthConsumer.getRequestToken();

            // Enter the Pin Code
            Console.WriteLine("Enter the pin code:");
            string pincode = Console.ReadLine();

            // Request Access Token
            oauthConsumer.getAccessToken(pincode);

            // Make an API Call (call the home_timeline status) and debug the response
            string response = (string)oauthConsumer.request("http://api.twitter.com/1/statuses/home_timeline.xml", "GET", null, "PLAIN");
            Console.WriteLine(response);
        }
예제 #2
0
        public static OAuthCredentials PerformOAuth(string consumerKey, string consumerSecret)
        {
            OAuthConfig oauthConfig = new OAuthConfig("console");
              oauthConfig.OauthVersion = "1.0";
              oauthConfig.OauthSignatureMethod = "HMAC-SHA1";

              oauthConfig.ConsumerKey = consumerKey;
              oauthConfig.ConsumerSecret = consumerSecret;

              oauthConfig.RequestTokenUrl = "https://api.twitter.com/oauth/request_token";
              oauthConfig.AccessTokenUrl = "https://api.twitter.com/oauth/access_token";
              oauthConfig.UserAuthorizationUrl = "https://api.twitter.com/oauth/authorize";

              OAuthConsumer oauthConsumer = new OAuthConsumer(oauthConfig, "console");
              oauthConsumer.getRequestToken();

              VerificationInput input = new VerificationInput();
              input.ShowDialog();
              string code = input.GetCode();
              oauthConsumer.getAccessToken(code);
              OAuthCredentials rv = new OAuthCredentials();
              rv.Token = oauthConfig.OauthToken;
              rv.Secret = oauthConfig.OauthTokenSecret;
              return rv;
        }