/// <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); }
public virtual void loginTwitter(object sender, EventArgs args) { // Change the button text buttonLogin.Text = "Complete authorization with Twitter"; // 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 = ConfigurationManager.AppSettings.Get("consumerKey"); oauthConfig.ConsumerSecret = ConfigurationManager.AppSettings.Get("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(); // After the authorization is completed with Twitter, OAuth will redirect you to the callbackURL declared in your application settings at dev.twitter.com // Information about the authenticated user is provided to that page in addition to the access token needed to execute further api calls }
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; }
public static OAuthConsumer CreateClient(string consumerKey, string consumerSecret, string accessToken, string accessSecret) { OAuthConfig oauthConfig = new OAuthConfig("console"); oauthConfig.OauthVersion = "1.0"; oauthConfig.OauthSignatureMethod = "HMAC-SHA1"; oauthConfig.ConsumerKey = consumerKey; oauthConfig.ConsumerSecret = consumerSecret; oauthConfig.OauthToken = accessToken; oauthConfig.OauthTokenSecret = accessSecret; OAuthConsumer oauthConsumer = new OAuthConsumer(oauthConfig, "console"); return oauthConsumer; }
/// <summary> /// With this test, the oauth access token created for the requester of the API key will be used and no authorization process will take place /// </summary> public void test_twitterOauthSuperClient() { // 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.OauthToken = TwitterOAuthTest._accessToken; oauthConfig.OauthTokenSecret = TwitterOAuthTest._accessTokenSecret; // Create an OAuth consumer OAuthConsumer oauthConsumer = new OAuthConsumer(oauthConfig, "console"); // 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); }
public OAuthConsumer(OAuthConfig oauthConfig, string debugType) : base(debugType) { this._oauthConfig = oauthConfig; }
public BTCTLink(string consumerKey, string consumerSecret, bool isBTCT, DebugHandler dh) { OAuthConfig oc; DebugHandler = dh; _consumerKey = consumerKey; _consumerSecret = consumerSecret; oc = new OAuthConfig(""); oc.SiteUrl = ""; oc.OauthVersion = "1.0"; oc.OauthSignatureMethod = "HMAC-SHA1"; oc.OauthCallback = "oob"; oc.OauthScope = "all"; oc.ConsumerKey = _consumerKey; oc.ConsumerSecret = _consumerSecret; _isBTCT = isBTCT; if (isBTCT) { _baseUrl = "https://btct.co/"; _coin = "BTC"; } else { _baseUrl = "https://www.litecoinglobal.com/"; _coin = "LTC"; } oc.RequestTokenUrl = _baseUrl + "oauth/request_token"; oc.AccessTokenUrl = _baseUrl + "oauth/access_token"; oc.UserAuthorizationUrl = _baseUrl + "authorize"; _oauthConsumer = new OAuthConsumer(oc, ""); _authStatus = AuthStatusType.AS_NONE; }