Exemple #1
0
        public static WindowsLiveResponse RefreshLiveToken(
            RefreshToken refreshToken)
        {
            RestClientEx client = ClientFactory("https://login.live.com",
                                                JsonNamingStrategy.SnakeCase);
            RestRequestEx       request = new RestRequestEx("oauth20_token.srf", Method.GET);
            NameValueCollection nv      = new Model.WindowsLiveRefreshQuery(refreshToken).GetQuery();

            request.AddQueryParameters(nv);
            IRestResponse <WindowsLiveResponse> response = client.Execute <WindowsLiveResponse>(request);

            return(response.Data);
        }
        /*
         * Static methods
         */

        /// <summary>
        /// Refreshes Access- and RefreshToken via the provided RefreshToken
        /// </summary>
        /// <param name="refreshToken">Windows Live refresh token</param>
        /// <returns>The gathered WindowsLiveResponse.</returns>
        public static async Task <WindowsLiveResponse> RefreshLiveTokenAsync(
            RefreshToken refreshToken)
        {
            logger.LogTrace("RefreshLiveTokenAsync() called");
            HttpClient client = ClientFactory("https://login.live.com/");

            var request    = new HttpRequestMessage(HttpMethod.Get, "oauth20_token.srf");
            var parameters = new Model.WindowsLiveRefreshQuery(refreshToken);

            request.AddQueryParameter(parameters.GetQuery());

            var response = (await client.SendAsync(request)).EnsureSuccessStatusCode();

            return(await response.Content.ReadAsJsonAsync <WindowsLiveResponse>(JsonNamingStrategy.SnakeCase));
        }