/// <summary> /// Method to run when successful authentication /// </summary> /// <param name="resp"></param> /// <param name="accessTokenExpiryCallback"></param> private void PostAuthentication(HttpResponseMessage resp) { var dateTimeNow = DateTime.Now; _auth = JsonConvert.DeserializeObject <AuthenticateResp>(resp.Content.ReadAsStringAsync().Result); _auth.expires_in_date = dateTimeNow.AddSeconds(_auth.expires_in); apiClient = new HttpClient(); apiClient.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", string.Format("{0} {1}", _auth.token_type, _auth.access_token)); apiClient.BaseAddress = new Uri(_auth.api_server); SuccessAuthEventArgs arg = new SuccessAuthEventArgs(); arg.TokenExpiry = _auth.expires_in_date; OnSuccessfulAuthentication(this, arg); }
/// <summary> /// Ctor for a wrapper for the Questrade API /// </summary> /// <param name="token">Refresh token</param> public Questrade(string token = "") { _auth = new AuthenticateResp(); _auth.refresh_token = token; authClient = new HttpClient(); if (notificationClient != null && notificationClient.State == System.Net.WebSockets.WebSocketState.Open) { isNotifiSubSuccess = true; } else { isNotifiSubSuccess = false; } if (quoteStreamClient != null && quoteStreamClient.State == System.Net.WebSockets.WebSocketState.Open) { isQuoteStreamSuccess = true; } else { isQuoteStreamSuccess = false; } }