How do I use OAuth to connect to the Etrade API?

前端 未结 5 926
滥情空心
滥情空心 2020-12-13 19:22

E-Trade released their API recently and provided technical documentation which is somewhat useful but not complete.

Does anyone have a fully working example in C#

5条回答
  •  青春惊慌失措
    2020-12-13 20:00

    To use the example class + GitHub's code from jejernig's answer, I used the following:

    TokenBase token = new TokenBase { ConsumerKey = "oauth_consumer_key from ETRADE" }; // OAuthRepository only seems to use the consumer key
    OAuthRepository rep = new OAuthRepository(token, "consumer_secret from ETRADE");
    OAuthSession session = rep.CreateSession();
    IToken accessToken = rep.GetAccessToken(session);
    

    I just removed the abstract from BaseOAuthRepository, and had to fix the GitHub code because IOAuthSession.GetUserAuthorizationUrlForToken()'s parameters were reversed (I changed the rest of the code to match the interface's parameters).

    I am getting the dreaded Due to a logon delay or other issue, your authentication could not be completed at this time. Please try again. message, but this may be due to an actual logon issue that I have to resolve.

提交回复
热议问题