Exemple #1
0
 private static void QTrade_OnSuccessfulAuthentication(object sender, SuccessAuthEventArgs e)
 {
     Console.WriteLine(string.Format("Access token will expire on: {0} {1}", e.TokenExpiry.ToLongDateString(), e.TokenExpiry.ToLongTimeString()));
     if (!(menuLoopTask.Status == TaskStatus.Running))
     {
         menuLoopTask.Start();
     }
 }
Exemple #2
0
        /// <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);
        }