示例#1
0
        private FileResult GetFileResult(OAuthAccessTokens oAuthAccessTokens)
        {
            string tokenString = JsonConvert.SerializeObject(oAuthAccessTokens);

            byte[] tokenByt = Encoding.UTF8.GetBytes(tokenString);

            return(this.File(tokenByt, "application/json", "tokens.json"));
        }
示例#2
0
        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);
        }