public void downloadFileContentsAndComputeMd5() { Hammock.Authentication.OAuth.OAuthCredentials credentials = OAuthWorkFlow.createOAuthCredentials(OAuthType.ProtectedResource, ApiCredentials.TOKEN.token, ApiCredentials.TOKEN.secret, null, null); Hammock.RestClient client = new Hammock.RestClient() { Authority = "", Credentials = credentials }; Hammock.RestRequest request = new Hammock.RestRequest() { Path = firstFileSelfUri }; request.AddHeader("Accept", "application/zip"); Hammock.RestResponse response = client.Request(request); checkFilenameInContentDispositionHeader(response); using (var md5 = MD5.Create()) { using (var stream = response.ContentStream) { md5FromSinglePieceDownload = md5.ComputeHash(stream); } } }
public void getRequestToken() { Hammock.Authentication.OAuth.OAuthCredentials credentials = createOAuthCredentials(OAuthType.RequestToken, null, null, null, "oob"); Hammock.RestClient client = new Hammock.RestClient() { Authority = "", Credentials = credentials }; Hammock.RestRequest request = new Hammock.RestRequest() { Path = links["oauthRequestToken"].uri }; Hammock.RestResponse response = client.Request(request); reqToken = response.Content.Split('&')[0]; authUri = cleanAuthorizationUri(links["oauthAuthorizeRequestToken"].uri) + "?" + reqToken; reqToken = reqToken.Split('=')[1]; reqSecret = response.Content.Split('&')[1].Split('=')[1]; }
private void GetTwitterToken() { var credentials = new OAuthCredentials { Type = OAuthType.RequestToken, SignatureMethod = OAuthSignatureMethod.HmacSha1, ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, ConsumerKey = Constants.ConsumerKey, ConsumerSecret = Constants.ConsumerKeySecret, Version = Constants.OAuthVersion, CallbackUrl = Constants.CallbackUri }; var client = new RestClient { Authority = "https://api.twitter.com/oauth", Credentials = credentials, HasElevatedPermissions = true, SilverlightAcceptEncodingHeader = "gizp", DecompressionMethods = DecompressionMethods.GZip, }; var request = new RestRequest { Path = "/request_token" }; client.BeginRequest(request, new RestCallback(TwitterRequestTokenCompleted)); }
private int makeHeadRequestToGetFileSize() { Hammock.Authentication.OAuth.OAuthCredentials credentials = OAuthWorkFlow.createOAuthCredentials(OAuthType.ProtectedResource, ApiCredentials.TOKEN.token, ApiCredentials.TOKEN.secret, null, null); Hammock.RestClient client = new Hammock.RestClient() { Authority = "", Credentials = credentials }; Hammock.RestRequest request = new Hammock.RestRequest() { Path = firstFileSelfUri, Method = WebMethod.Head }; request.AddHeader("Accept", "application/zip"); Hammock.RestResponse response = client.Request(request); /*if (!hasResponseCode(OK).matches(headRes)) { * firstFileSelfUri = null; * //fail(format("HEAD request to %s returned bad response code", firstFileSelfUri)); * }*/ //checkThat("Content-Length header", headRes.getHeaderFields().contains("Content-Length"), isTrue()); return(Convert.ToInt32(response.Headers["Content-Length"])); //return Integer.valueOf(headRes.getHeaderFields().valueOf("Content-Length")); }
/// <summary> /// Initializes a new instance of the <see cref="Client"/> class. /// </summary> /// <param name="oauthCredentials">The oauth credentials.</param> public Client(OAuthCredentials oauthCredentials) : this() { if (oauthCredentials == null) { throw new ArgumentNullException("oauthCredentials"); } if (string.IsNullOrWhiteSpace(oauthCredentials.ConsumerKey)) { throw new ArgumentOutOfRangeException("oauthCredentials", "ConsumerKey must not be empty"); } if (string.IsNullOrWhiteSpace(oauthCredentials.ConsumerSecret)) { throw new ArgumentOutOfRangeException("oauthCredentials", "ConsumerSecret must not be empty"); } Authority = AUTHORITY; VersionPath = VERSIONPATH; Credentials = oauthCredentials; UserAgent = "simplegeo.Net Client Application"; }
public static void CallDailyBurnApiDelete(string apiExtensionPath, RestCallback callback) { string accessToken = HelperMethods.GetKeyValue("accessToken"); string accessTokenSecret = HelperMethods.GetKeyValue("accessTokenSecret"); var credentials = new OAuthCredentials { Type = OAuthType.ProtectedResource, SignatureMethod = OAuthSignatureMethod.HmacSha1, ParameterHandling = OAuthParameterHandling.UrlOrPostParameters, ConsumerKey = DailyBurnSettings.consumerKey, ConsumerSecret = DailyBurnSettings.consumerKeySecret, Token = accessToken, TokenSecret = accessTokenSecret, Version = "1.0" }; var restClient = new RestClient { Authority = DailyBurnSettings.AuthorityUri, HasElevatedPermissions = true, Credentials = credentials, Method = WebMethod.Delete }; var restRequest = new RestRequest { Path = apiExtensionPath, Method = WebMethod.Delete }; restClient.BeginRequest(restRequest, new RestCallback(callback)); }
public void getFiles() { Hammock.Authentication.OAuth.OAuthCredentials credentials = OAuthWorkFlow.createOAuthCredentials(OAuthType.ProtectedResource, ApiCredentials.TOKEN.token, ApiCredentials.TOKEN.secret, null, null); Hammock.RestClient client = new Hammock.RestClient() { Authority = "", Credentials = credentials }; Hammock.RestRequest request = new Hammock.RestRequest() { Path = links["files"].uri }; request.AddHeader("Accept", "application/vnd.deere.axiom.v3+json"); Hammock.RestResponse response = client.Request(request); CollectionPageDeserializer ds = new CollectionPageDeserializer(); files = ds.deserialize <SampleApp.Sources.generated.v3.File>(response.Content); Console.WriteLine("done"); }
public void retrieveApiCatalog() { Hammock.Authentication.OAuth.OAuthCredentials credentials = OAuthWorkFlow.createOAuthCredentials(OAuthType.ProtectedResource, ApiCredentials.TOKEN.token, ApiCredentials.TOKEN.secret, null, null); Hammock.RestClient client = new Hammock.RestClient() { Authority = "", Credentials = credentials }; Hammock.RestRequest request = new Hammock.RestRequest() { Path = "https://apicert.soa-proxy.deere.com/platform/" }; request.AddHeader("Accept", "application/vnd.deere.axiom.v3+json"); Hammock.RestResponse response = client.Request(request); ApiCatalog apiCatalog = Deserialise <ApiCatalog>(response.ContentStream); links = OAuthWorkFlow.linksFrom(apiCatalog); getFiles(); retrieveMetadataForFile(); downloadFileContentsAndComputeMd5(); downloadFileInPiecesAndComputeMd5(); }
public TwitterClient(IRestClient client, string consumerKey, string consumerSecret, string callback) : base(client) { Encode = true; Statuses = new Statuses(this); Account = new Account(this); DirectMessages = new DirectMessages(this); Favourites = new Favourites(this); Block = new Block(this); Friendships = new Friendship(this); Lists = new List(this); Search = new Search(this); Users = new Users(this); FriendsAndFollowers = new FriendsAndFollowers(this); OAuthBase = "https://api.twitter.com/oauth/"; TokenRequestUrl = "request_token"; TokenAuthUrl = "authorize"; TokenAccessUrl = "access_token"; Authority = "https://api.twitter.com/"; Version = "1"; #if !SILVERLIGHT ServicePointManager.Expect100Continue = false; #endif Credentials = new OAuthCredentials { ConsumerKey = consumerKey, ConsumerSecret = consumerSecret, }; if (!string.IsNullOrEmpty(callback)) ((OAuthCredentials)Credentials).CallbackUrl = callback; }
public void retrieveMetadataForFile() { Dictionary <String, Link> linksFromFirstFile = OAuthWorkFlow.linksFrom(files.page[3]); firstFileSelfUri = linksFromFirstFile["self"].uri; Hammock.Authentication.OAuth.OAuthCredentials credentials = OAuthWorkFlow.createOAuthCredentials(OAuthType.ProtectedResource, ApiCredentials.TOKEN.token, ApiCredentials.TOKEN.secret, null, null); Hammock.RestClient client = new Hammock.RestClient() { Authority = "", Credentials = credentials }; Hammock.RestRequest request = new Hammock.RestRequest() { Path = firstFileSelfUri }; request.AddHeader("Accept", "application/vnd.deere.axiom.v3+json"); Hammock.RestResponse response = client.Request(request); SampleApp.Sources.generated.v3.File firstFileDetails = Deserialise <SampleApp.Sources.generated.v3.File>(response.ContentStream); filename = firstFileDetails.name; }
public TwitterHelper() { _twitterSettings = Helper.LoadSetting<TwitterAccess>(Constants.TwitterAccess); if (_twitterSettings == null || String.IsNullOrEmpty(_twitterSettings.AccessToken) || String.IsNullOrEmpty(_twitterSettings.AccessTokenSecret)) { return; } _authorized = true; _credentials = new OAuthCredentials { Type = OAuthType.ProtectedResource, SignatureMethod = OAuthSignatureMethod.HmacSha1, ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, ConsumerKey = TwitterSettings.ConsumerKey, ConsumerSecret = TwitterSettings.ConsumerKeySecret, Token = _twitterSettings.AccessToken, TokenSecret = _twitterSettings.AccessTokenSecret, Version = TwitterSettings.OAuthVersion, }; _client = new RestClient { Authority = "http://api.twitter.com", HasElevatedPermissions = true }; }
public string GetTwitterRedirectUrl(string consumerKey, string consumerSecret, string CallBackUrl) { OAuthCredentials credentials = new OAuthCredentials() { Type = OAuthType.RequestToken, SignatureMethod = OAuthSignatureMethod.HmacSha1, ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, ConsumerKey = consumerKey, ConsumerSecret = consumerSecret, CallbackUrl = CallBackUrl }; // Use Hammock to create a rest client var client = new RestClient { Authority = "https://api.twitter.com/oauth", Credentials = credentials }; // Use Hammock to create a request var request = new RestRequest { Path = "request_token" }; // Get the response from the request var response = client.Request(request); var collection = HttpUtility.ParseQueryString(response.Content); //string str = collection[1].ToString(); //HttpContext.Current.Session["requestSecret"] = collection[1]; string rest = "https://api.twitter.com/oauth/authorize?oauth_token=" + collection[0] + "~" + collection[1]; return rest; }
public void retrieveApiCatalogToEstablishOAuthProviderDetails() { Hammock.Authentication.OAuth.OAuthCredentials credentials = createOAuthCredentials(OAuthType.ProtectedResource, null, null, null, null); Hammock.RestClient client = new Hammock.RestClient() { Authority = "https://apicert.soa-proxy.deere.com/platform/", Credentials = credentials }; Hammock.RestRequest request = new Hammock.RestRequest() { Path = "" }; request.AddHeader("Accept", "application/vnd.deere.axiom.v3+json"); Hammock.RestResponse response = client.Request(request); MemoryStream stream1 = new MemoryStream(); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(ApiCatalog)); stream1.Position = 0; ApiCatalog apiCatalog = (ApiCatalog)ser.ReadObject(response.ContentStream); links = linksFrom(apiCatalog); }
internal TwitterStream(OAuthCredentials credential, string authority, RestRequest request=null) { _credential = credential; _authority = authority; if (request != null) Request = request; else Request = new RestRequest(); }
public void GetRequestToken(OAuthCredentials oaCredentials) { oaCredentials.Type = OAuthType.RequestToken; RestRequest rrRequest = new RestRequest { Path = C_REQUEST_TOKEN_URL }; DoRequest(rrRequest, oaCredentials, new APIReturn(GetRequestTokenCallback, null, oaCredentials)); }
private Hammock.RestClient getRestClient() { Hammock.Authentication.OAuth.OAuthCredentials credentials = OAuthWorkFlow.createOAuthCredentials(OAuthType.ProtectedResource, ApiCredentials.TOKEN.token, ApiCredentials.TOKEN.secret, null, null); Hammock.RestClient client = new Hammock.RestClient() { Authority = "", Credentials = credentials }; return(client); }
public static OAuthCredentials ForRequestToken(string consumerKey, string consumerSecret) { var credentials = new OAuthCredentials { Type = OAuthType.RequestToken, ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, SignatureMethod = OAuthSignatureMethod.HmacSha1, SignatureTreatment = OAuthSignatureTreatment.Escaped, ConsumerKey = consumerKey, ConsumerSecret = consumerSecret }; return credentials; }
//protected void DoRequest(string sEndpoint, WebMethod wmTransferType, Dictionary<string, string> dssParams, APIReturn aprReturn) protected void DoRequest(RestRequest rrRequest, OAuthCredentials oaCredentials, APIReturn aprReturn) { //suggested by the smart guys at dev.twitter.com rrRequest.AddParameter("oauth_callback", "oob"); RestClient rcClient = new RestClient { Authority = C_OAUTH_BASE_URL, Credentials = oaCredentials }; //post request, update credentials object rcClient.BeginRequest(rrRequest, DoRequestCallback, aprReturn); }
protected override IWebCredentials GetAuthorizationTokenCredentials() { OAuthCredentials credentials = new OAuthCredentials() { Type = OAuthType.RequestToken, SignatureMethod = OAuthSignatureMethod.HmacSha1, ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, ConsumerKey = SensitiveData.ConsumerToken, ConsumerSecret = SensitiveData.ConsumerSecret, CallbackUrl = callbackUrl, Version = "1.0a" }; return credentials; }
private void InitializeFromCredentials(OAuthCredentials credentials) { ConsumerKey = credentials.ConsumerKey; ConsumerSecret = credentials.ConsumerSecret; ParameterHandling = credentials.ParameterHandling; SignatureMethod = credentials.SignatureMethod; SignatureTreatment = credentials.SignatureTreatment; Token = credentials.Token; TokenSecret = credentials.TokenSecret; Verifier = credentials.Verifier; ClientUsername = credentials.ClientUsername; ClientPassword = credentials.ClientPassword; CallbackUrl = credentials.CallbackUrl; Version = credentials.Version; SessionHandle = credentials.SessionHandle; }
public static Hammock.Authentication.OAuth.OAuthCredentials createOAuthCredentials(OAuthType type, String strToken, String strSecret, String strVerifier, String strCallBack ) { Hammock.Authentication.OAuth.OAuthCredentials credentials = new Hammock.Authentication.OAuth.OAuthCredentials() { Type =type, SignatureMethod = Hammock.Authentication.OAuth.OAuthSignatureMethod.HmacSha1, ParameterHandling = Hammock.Authentication.OAuth.OAuthParameterHandling.HttpAuthorizationHeader, ConsumerKey = SampleApp.Sources.democlient.ApiCredentials.CLIENT.key, ConsumerSecret = SampleApp.Sources.democlient.ApiCredentials.CLIENT.secret, Token = strToken, TokenSecret = strSecret, Verifier = strVerifier, CallbackUrl = strCallBack }; return credentials; }
public static Hammock.Authentication.OAuth.OAuthCredentials createOAuthCredentials(OAuthType type, String strToken, String strSecret, String strVerifier, String strCallBack) { Hammock.Authentication.OAuth.OAuthCredentials credentials = new Hammock.Authentication.OAuth.OAuthCredentials() { Type = type, SignatureMethod = Hammock.Authentication.OAuth.OAuthSignatureMethod.HmacSha1, ParameterHandling = Hammock.Authentication.OAuth.OAuthParameterHandling.HttpAuthorizationHeader, ConsumerKey = SampleApp.Sources.democlient.ApiCredentials.CLIENT.key, ConsumerSecret = SampleApp.Sources.democlient.ApiCredentials.CLIENT.secret, Token = strToken, TokenSecret = strSecret, Verifier = strVerifier, CallbackUrl = strCallBack }; return(credentials); }
public ActionResult Callback() { token = Request["oauth_token"]; verifier = Request["oauth_verifier"]; var credentials = new OAuthCredentials { ConsumerKey = ConfigurationManager.AppSettings["ConsumerKey"], ConsumerSecret = ConfigurationManager.AppSettings["ConsumerSecret"], Token = token, TokenSecret = token_secret, Verifier = verifier, Type = OAuthType.AccessToken, ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, SignatureMethod = OAuthSignatureMethod.HmacSha1, Version = "1.0" }; var client = new RestClient { Authority = "https://api.linkedin.com/uas/oauth", Credentials = credentials, Method = WebMethod.Post }; var request = new RestRequest { Path = "accessToken" }; RestResponse response = client.Request(request); string content = response.Content; string accessToken = response.Content.Split('&').Single(s => s.StartsWith("oauth_token=")).Split('=')[1]; string accessTokenSecret = response.Content.Split('&').Single(s => s.StartsWith("oauth_token_secret=")).Split('=')[1]; //string accessToken = response.Content.Split('&').Where(s = > s.StartsWith("oauth_token=")).Single().Split('=')[1]; //string accessTokenSecret = response.Content.Split('&').Where(s = > s.StartsWith("oauth_token_secret=")).Single().Split('=')[1]; //var company = new LinkedInService(accessToken, accessTokenSecret).GetCompany(162479); // Some commented call to API //company = new LinkedInService(accessToken, accessTokenSecret).GetCompanyByUniversalName("linkedin"); // var companies = new LinkedInService(accessToken, accessTokenSecret).GetCompaniesByEmailDomain("apple.com"); // var companies1 = new LinkedInService(accessToken, accessTokenSecret).GetCompaniesByEmailDomain("linkedin.com"); // var companies2= new LinkedInService(accessToken, accessTokenSecret).GetCompaniesByIdAnduniversalName("162479", "linkedin"); //var people = new LinkedInService(accessToken, accessTokenSecret).GetPersonById("f7cp5sKscd"); //var people = new LinkedInService(accessToken, accessTokenSecret).GetCurrentUser(); //string url = Url.Encode("http://bd.linkedin.com/pub/rakibul-islam/37/522/653"); //var people = new LinkedInService(accessToken, accessTokenSecret).GetPeoPleByPublicProfileUrl(url); //var peopleSearchresult = new LinkedInService(accessToken, accessTokenSecret).SearchPeopleByKeyWord("Princes"); //var peopleSearchresult = new LinkedInService(accessToken, accessTokenSecret).GetPeopleByFirstName("Mizan"); var currUser = new LinkedInService(accessToken,accessTokenSecret).GetCurrentUser(); //String companyName = company.Name; return Content($"{currUser.FirstName} {currUser.LastName} {currUser.headLine}"); }
public UserStream(OAuthCredentials oaCredentials) { m_oaCredentials = oaCredentials; m_bscAPI = new BasicAPI(m_oaCredentials); m_rcClient = new RestClient { Authority = C_BASE_URL, VersionPath = C_VERSION_PATH, Credentials = m_oaCredentials, Method = WebMethod.Get, StreamOptions = new StreamOptions { ResultsPerCallback = 1 } }; }
private void getChunkFromStartAndRecurse(int start, int chunkSize, int fileSize //,DigestOutputStream byteDigest ) { int maxRange = fileSize - 1; int end = Math.Min(start + chunkSize, maxRange); Hammock.Authentication.OAuth.OAuthCredentials credentials = OAuthWorkFlow.createOAuthCredentials(OAuthType.ProtectedResource, ApiCredentials.TOKEN.token, ApiCredentials.TOKEN.secret, null, null); Hammock.RestClient client = new Hammock.RestClient() { Authority = "", Credentials = credentials }; Hammock.RestRequest request = new Hammock.RestRequest() { Path = firstFileSelfUri, Method = WebMethod.Get }; request.AddHeader("Accept", "application/zip"); request.AddHeader("Range", "bytes=" + start + "-" + end); Hammock.RestResponse response = client.Request(request); using (var md5 = MD5.Create()) { using (var stream = response.ContentStream) { md5FromMultiplePieceDownload = md5.ComputeHash(stream); } } checkFilenameInContentDispositionHeader(response); // copy(rangeResponse.getBody(), byteDigest); if (start + chunkSize < maxRange) { getChunkFromStartAndRecurse(start + chunkSize + 1, chunkSize, fileSize); } }
/// <summary> /// Creates a streaming client and authenticates the client for reading from the logged in user /// </summary> /// <param name="consumerkey"></param> /// <param name="consumersecret"></param> public TwitterClient(string consumerkey, string consumersecret, string accessToken, string accessTokenSecret) { ConsumerKey = consumerkey; ConsumerSecret = consumersecret; AccessToken = accessToken; AccessTokenSecret = accessTokenSecret; if (AccessToken != "" && AccessTokenSecret != "") _credentials = new OAuthCredentials { Type = OAuthType.ProtectedResource, Token = AccessToken, TokenSecret = AccessTokenSecret, ConsumerKey = ConsumerKey, ConsumerSecret = ConsumerSecret }; }
public ActionResult Callback(string oauth_token, string oauth_verifier) { var requestSecret = (string)Session["requestSecret"]; var credentials = new OAuthCredentials { Type = OAuthType.AccessToken, SignatureMethod = OAuthSignatureMethod.HmacSha1, ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, ConsumerKey = Config.TwitterConsumerKey, ConsumerSecret = Config.TwitterConsumerSecret, Token = oauth_token, TokenSecret = requestSecret, Verifier = oauth_verifier, }; var client = new RestClient() { Authority = "https://twitter.com/oauth", Credentials = credentials, }; var request = new RestRequest { Path = "/access_token" }; var response = client.Request(request); var collection = HttpUtility.ParseQueryString(response.Content); var token = collection["oauth_token"]; var tokenSecret = collection["oauth_token_secret"]; var info = Twitter.GetUserInformation(token, tokenSecret); var user = (User)Session["user"] ?? new User(); user.TwitterAccessToken = token; user.TwitterAccessTokenSecret = tokenSecret; user.TwitterUser = info; Session["user"] = user; return RedirectToAction("Index", "Tubuyaki"); }
private void m_oaApi_AccessTokenReceived(object sender, bool bSucceeded, string sErrorMessage, OAuthCredentials oaCredentials) { if (bSucceeded) { m_oaCredentials = oaCredentials; ToggleLoadingAnimation(false); ToggleButtons(true); m_aaStatus = (AddAccountStatus)((int)m_aaStatus + 1); UpdateFromStatus(); } else { MessageBox.Show(sErrorMessage, "OAuth Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); m_aaStatus = AddAccountStatus.Pin; UpdateFromStatus(); ToggleButtons(true); ToggleLoadingAnimation(false); } }
public void exchangeRequestTokenForAccessToken() { Hammock.Authentication.OAuth.OAuthCredentials credentials = createOAuthCredentials(OAuthType.AccessToken, reqToken, HttpUtility.UrlDecode(reqSecret), verifier, null); Hammock.RestClient client = new Hammock.RestClient() { Authority = "", Credentials = credentials }; Hammock.RestRequest request = new Hammock.RestRequest() { Path = links["oauthAccessToken"].uri }; Hammock.RestResponse response = client.Request(request); Console.WriteLine("Token:" + response.Content.Split('&')[0].Split('=')[1] + " \n Token Secret:" + response.Content.Split('&')[1].Split('=')[1]); }
public static void CallDailyBurnApi(string apiExtensionPath, RestCallback callback, Dictionary<string, string> parameters) { string accessToken = HelperMethods.GetKeyValue("accessToken"); string accessTokenSecret = HelperMethods.GetKeyValue("accessTokenSecret"); var credentials = new OAuthCredentials { Type = OAuthType.ProtectedResource, SignatureMethod = OAuthSignatureMethod.HmacSha1, ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, ConsumerKey = DailyBurnSettings.consumerKey, ConsumerSecret = DailyBurnSettings.consumerKeySecret, Token = accessToken, TokenSecret = accessTokenSecret, Version = "1.0" }; var restClient = new RestClient { Authority = DailyBurnSettings.AuthorityUri, HasElevatedPermissions = true, Credentials = credentials, Method = WebMethod.Get }; var restRequest = new RestRequest { Path = apiExtensionPath, Method = WebMethod.Get }; if (parameters != null) { foreach (KeyValuePair<string, string> param in parameters) { restRequest.AddParameter(param.Key, param.Value); } } restClient.BeginRequest(restRequest, new RestCallback(callback)); }
public ActionResult AuthenticateToLinkedIn() { var credentials = new Hammock.Authentication.OAuth.OAuthCredentials { CallbackUrl = "http://localhost:53130/Linkedin/callback", ConsumerKey = ConfigurationManager.AppSettings["ConsumerKey"], ConsumerSecret = ConfigurationManager.AppSettings["ConsumerSecret"], Verifier = "123456", Type = OAuthType.RequestToken }; var client = new RestClient { Authority = "https://api.linkedin.com/uas/oauth", Credentials = credentials }; var request = new RestRequest { Path = "requestToken" }; RestResponse response = client.Request(request); token = response.Content.Split('&').Single(s => s.StartsWith("oauth_token=")).Split('=')[1]; token_secret = response.Content.Split('&').Single(s => s.StartsWith("oauth_token_secret=")).Split('=')[1]; Response.Redirect("https://api.linkedin.com/uas/oauth/authorize?oauth_token=" + token); return null; }
public void getRequestToken() { Hammock.Authentication.OAuth.OAuthCredentials credentials = createOAuthCredentials(OAuthType.RequestToken, null, null, null, "https://developer.deere.com/oauth/auz/grants/provider/authcomplete"); Hammock.RestClient client = new Hammock.RestClient() { Authority = "", Credentials = credentials }; Hammock.RestRequest request = new Hammock.RestRequest() { Path = links["oauthRequestToken"].uri }; Hammock.RestResponse response = client.Request(request); reqToken = response.Content.Split('&')[0]; authUri = links["oauthAuthorizeRequestToken"].uri + "?" + reqToken; reqToken = reqToken.Split('=')[1]; reqSecret = response.Content.Split('&')[1].Split('=')[1]; }
public RedirectResult Auth() { var requestToken = Request.QueryString["oauth_token"]; var requestSecret = (string)Session["requestSecret"]; var requestVerifier = Request.QueryString["oauth_verifier"]; var credentials2 = new OAuthCredentials { Type = OAuthType.AccessToken, SignatureMethod = OAuthSignatureMethod.HmacSha1, ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, ConsumerKey = _consumerKey, ConsumerSecret = _consumerSecret, Token = requestToken, TokenSecret = requestSecret, Verifier = requestVerifier }; var client2 = new RestClient() { Authority = "http://www.h2oscore.com/oauth", Credentials = credentials2 }; var request2 = new RestRequest { Path = "/access_token" }; RestResponse response2 = client2.Request(request2); var collection = HttpUtility.ParseQueryString(response2.Content); Session["accessToken"] = collection["oauth_token"]; Session["accessSecret"] = collection["oauth_token_secret"]; return new RedirectResult("/"); }
private void Reset() { ToggleButtons(true); //get empty set of credentials m_oaCredentials = OAuthAPI.GetCredentials("", ""); m_aaStatus = (AddAccountStatus)0; UpdateFromStatus(); txtPin.Text = ""; txtUrl.Text = ""; }
private void GetAccessToken(string uri) { var requestToken = GetQueryParameter(uri, "oauth_token"); if (requestToken != _oAuthToken) { MessageBox.Show("Twitter auth tokens don't match"); } var requestVerifier = GetQueryParameter(uri, "oauth_verifier"); var credentials = new OAuthCredentials { Type = OAuthType.AccessToken, SignatureMethod = OAuthSignatureMethod.HmacSha1, ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, ConsumerKey = TwitterSettings.ConsumerKey, ConsumerSecret = TwitterSettings.ConsumerKeySecret, Token = _oAuthToken, TokenSecret = _oAuthTokenSecret, Verifier = requestVerifier }; var client = new RestClient { Authority = "https://api.twitter.com/oauth", Credentials = credentials, HasElevatedPermissions = true, SilverlightAcceptEncodingHeader = "GZip", DecompressionMethods = DecompressionMethods.GZip }; var request = new RestRequest { Path = "/access_token" }; client.BeginRequest(request, new RestCallback(RequestAccessTokenCompleted)); }
public BaseAPI(OAuthCredentials oaCredentials) { m_oaCredentials = oaCredentials; }
/// <summary> /// Creates a new instance of <see cref="OAuthWorkflow" /> using /// an <see cref="OAuthCredentials" /> instance. /// </summary> /// <param name="credentials">The credentials to copy</param> public OAuthWorkflow(OAuthCredentials credentials) { InitializeFromCredentials(credentials); }
protected override IWebCredentials GetCredentials(NameValueCollection parameters) { OAuthCredentials credentials = new OAuthCredentials() { Type = OAuthType.RequestToken, SignatureMethod = OAuthSignatureMethod.HmacSha1, ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, ConsumerKey = SensitiveData.ConsumerToken, ConsumerSecret = SensitiveData.ConsumerSecret, Token = parameters["oauth_token"], TokenSecret = request_token_secret, Verifier = parameters["oauth_verifier"], CallbackUrl = callbackUrl, Version = "1.0a" }; return credentials; }
private void postMessageToTwitter() { var credentials = new OAuthCredentials { Type = OAuthType.ProtectedResource, SignatureMethod = OAuthSignatureMethod.HmacSha1, ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, ConsumerKey = AppSettings.TwitterConsumerKey, ConsumerSecret = AppSettings.TwitterConsumerKeySecret, Token = this.accessToken, TokenSecret = this.accessTokenSecret, Version = "1.0" }; var restClient = new RestClient { Authority = AppSettings.TwitterStatusUpdateUrl, HasElevatedPermissions = true, Credentials = credentials, Method = WebMethod.Post }; restClient.AddHeader("Content-Type", "application/x-www-form-urlencoded"); var restRequest = new RestRequest { Path = "1/statuses/update.xml?status=" + this.postMessage }; var ByteData = Encoding.UTF8.GetBytes(this.postMessage); restRequest.AddPostContent(ByteData); restClient.BeginRequest(restRequest, new RestCallback(postFinished)); }
public ActionResult LoginWithTwitter() { var credentials = new OAuthCredentials { Type = OAuthType.RequestToken, SignatureMethod = OAuthSignatureMethod.HmacSha1, ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, ConsumerKey = Config.TwitterConsumerKey, ConsumerSecret = Config.TwitterConsumerSecret, CallbackUrl = Config.ApplicationUrl + "/Account/Callback", }; var client = new RestClient { Authority = "https://twitter.com/oauth", Credentials = credentials }; var request = new RestRequest { Path = "/request_token" }; var response = client.Request(request); var collection = HttpUtility.ParseQueryString(response.Content); Session["requestSecret"] = collection[1]; return Redirect("https://twitter.com/oauth/authenticate?oauth_token=" + collection[0]); }
public void GetAccessToken(OAuthCredentials oaCredentials, string sPin = null) { oaCredentials.Type = OAuthType.AccessToken; RestRequest rrRequest = new RestRequest { Path = C_ACCESS_TOKEN_URL }; if (sPin != null) oaCredentials.Verifier = sPin; DoRequest(rrRequest, oaCredentials, new APIReturn(GetAccessTokenCallback, null, oaCredentials)); }
public OAuthResponseObject(RestResponseHash rrhResponse, OAuthCredentials oaCredentials) { m_rrhResponse = rrhResponse; m_oaCredentials = oaCredentials; }