private FileResult GetFileResult(OAuthAccessTokens oAuthAccessTokens) { string tokenString = JsonConvert.SerializeObject(oAuthAccessTokens); byte[] tokenByt = Encoding.UTF8.GetBytes(tokenString); return(this.File(tokenByt, "application/json", "tokens.json")); }
protected virtual OAuthAccessTokens GetOAuthTokensFromResponse(HttpWebResponse response) { StreamReader streamReader = new StreamReader(response.GetResponseStream()); OAuthAccessTokens tokens = null; using (JsonTextReader textReader = new JsonTextReader(streamReader)) { JsonSerializer serializer = new JsonSerializer(); tokens = serializer.Deserialize <OAuthAccessTokens>(textReader); tokens.Acquired = DateTime.UtcNow; } return(tokens); }