public async Task <IActionResult> OnGet() { this.Token = this.Request.GetCookie <DexcomToken>(this.cookieName); if (this.Token == null) { return(this.Redirect(this.apiAccess.OauthUri)); } var response = await this.apiAccess.GetDataRange(this.Token.AccessToken).ConfigureAwait(false); if (response.StatusCode == HttpStatusCode.Unauthorized) { var newToken = await this.apiAccess.GetAccessTokenAsync(this.Token.RefreshToken, true).ConfigureAwait(false); this.Response.SaveCookie <DexcomToken>(this.cookieName, newToken); this.Token = newToken; response = await this.apiAccess.GetDataRange(this.Token.AccessToken).ConfigureAwait(false); } var json = response.Content; this.DataRangeJson = json; this.DataRange = json.ToObject <DataRange>(); return(this.Page()); }
public async Task <IActionResult> OnGet() { this.Token = this.Request.GetCookie <DexcomToken>(this.cookieName); if (this.Token == null) { return(this.Redirect(this.apiAccess.OauthUri)); } var response = await this.apiAccess.GetEgvs(this.Token.AccessToken).ConfigureAwait(false); if (response.StatusCode == HttpStatusCode.Unauthorized) { var newToken = await this.apiAccess.GetAccessTokenAsync(this.Token.RefreshToken, true).ConfigureAwait(false); this.Response.SaveCookie <DexcomToken>(this.cookieName, newToken); this.Token = newToken; response = await this.apiAccess.GetEgvs(this.Token.AccessToken).ConfigureAwait(false); } var json = response.Content; this.EgvList = json.ToObject <EgvList>(); var dateTimeFormat = this.configuration["DateTimeQueryFormat"]; var dataPoints = this.EgvList.Egvs.Select(e => new { x = e.DisplayTime.ToString(dateTimeFormat, CultureInfo.InvariantCulture), y = e.Value }); this.EgvJson = dataPoints.ToJson(); return(this.Page()); }
public async Task <IActionResult> OnGet(string code) { this.Token = await this.apiAccess.GetAccessTokenAsync(code).ConfigureAwait(false); this.Response.SaveCookie <DexcomToken>(this.cookieName, this.Token); return(this.Page()); }
public IActionResult OnGet() { var json = this.Request.Cookies[this.cookieName]; if (string.IsNullOrWhiteSpace(json)) { this.DexcomToken = null; } else { this.DexcomToken = JsonConvert.DeserializeObject <DexcomToken>(json); } return(this.Page()); }