E-Trade has recently released its API and provided it.
Does anyone get a fully working example in C # that this shows how it works?
I am able to authenticate using OAuth, but when it comes to obtaining information my account or market data, server fails
I was able to connect using the DevDefined OAuth Library, but I had to do some tweeks to source it to work properly. I suppressed the repo so that you can download the src I used, and you can create a .dll.
Repos:
Example Category:
Public Abstract Class BaseOAuthRepository {Private Static String REQUEST_URL = "https://etws.etrade.com/ OAuth / request_token "; Private static string AUTHORIZE_URL = "https://us.etrade.com/e/t/etws/authorize"; Private static string ACCESS_URL = "https://etws.etrade.com/oauth/access_token"; Private Readonly Tokenbase _ Tokenbase; Private ReDonline string _consumerSecret; Secure BaseOAuthRepository (TokenBase TokenBase, String ConsumerSoftware) {_tokenbase = Tokenbase; _consumerSecret = ConsumerCyct; } Get public tokenbase mitochonbase {get {back _tokenBase; }} Public string MyConsumerSecret {get {return _consumerSecret; }} Public OAuthSession CreateSession () {var ConsumerContext = New OAuthConsumerContext {ConsumerKey = MyTokenBase.ConsumerKey, ConsumerSecret = MyConsumerSecret, SignatureMethod = SignatureMethod.HmacSha1, UseHeaderForOAuthParameters = true, CallBack = "oob"}; Var session = new OAuthSession (Consumer Conscious, REQUEST_URL, AUTHORIZE_URL, ACCESS_URL); Return session; } Public ITCA GateAvsetToken (OAT Session Session) {ITCUG RequestsToken = Session.GetryWest Token (); String authentication link = session. Geturess Authority Url Fürsten (MyTokenbes.Concemaker, RequestToken); Process.Start (authorizationLink); Console Type ("Please enter the PIN from the browser:"); String pin = console.readline (); Iitocon AccessToken = Session ExchangesTokenFourXToken (RequestToken, PinOutuper ()); Return Access Token; } Public string GetResponse (OAuthSession session, string url) {IToken accessToken = MyTokenBase; Var response = session. Request (AccessToken). (). ForUrl (url) .toString (); Return feedback; } Public XDocument GetWebResponseAsXml (HttpWebResponse response) {XmlReader xmlReader = XmlReader.Create (response.GetResponseStream ()); XDocument xdoc = XDocument.Load (xmlReader); XmlReader.Close (); Return xdoc; } Public string GetWebResponseAsString (HttpWebResponse response) {Encoding enc = System.Text.Encoding.GetEncoding (1252); Streamrider lorrosporststream = new streamerdidder (feedback gatesresponsstream (), ac); Return loRsponseStream.ReadToEnd (); }}
Comments
Post a Comment