public MarketConnectionManager(string apiKey, int timeout = 100, string accessToken = null, bool debug = false, bool microCache = true) { this._apiKey = apiKey; this._accessToken = accessToken; this._microCache = microCache; this._httpOperations = new HttpOperations(apiKey, timeout, accessToken, debug, microCache); }
/// <summary> /// curl https://api.kite.trade/session/token /// -d "api_key=xxx" /// -d "request_token=yyy" /// -d "checksum=zzz" /// Authentication involves redirecting a user /// to the public Kite login endpoint /// https://kite.trade/connect/login?api_key=xxx. /// A successful login comes /// back with a request_token /// as a URL query parameter to /// the registered redirect url. /// Gets the accesstoken /// response contains not just the `access_token`, but metadata for /// the user who has authenticated. /// </summary> /// <param name="requestToken">The request token you got after login</param> /// <param name="secret">your API secret</param> /// </returns> public dynamic RequestAccessToken(string requestToken, string secret) { //Do the token exchange with the `request_token` obtained after the login flow, //and retrieve the `access_token` required for all subsequent requests.The //response contains not just the `access_token`, but metadata for //the user who has authenticated. //- `request_token` is the token obtained from the GET paramers after a successful login redirect. //- `secret` is the API secret issued with the API key. // h = hashlib.sha256(self.api_key.encode("utf-8") + request_token.encode("utf-8") + secret.encode("utf-8")) string checksum = HttpOperations.Sha256(this._apiKey + requestToken + secret); var values = new Dictionary <string, string> { { "request_token", requestToken }, { "checksum", checksum } }; //_httpOperations.SetAccessToken(requestToken); dynamic resp = _httpOperations.Post(Route.API_VALIDATE, values); if ((resp != null) && resp.ContainsKey("access_token")) { SetAccessToken(resp["access_token"]); } return(resp); }
public void Setup() { mockOperations = new Mock <HttpOperations>(); mockOperations.CallBase = true; httpOperations = mockOperations.Object; httpOperations.Init(apikey, "bacon"); var mockHttp = new Mock <WrappedHttpClient>(true); mockHttp.CallBase = true; httpOperations.http = mockHttp.Object; httpOperations.http.MockedResponse = new HttpResponse(null); var reader = new JsonReader(); fileFoundResponse = reader.Read("{\"download_url\": \"a_url\", \"job\": \"a_job\"}"); }