Read() public method

public Read ( HttpContext context ) : OAuthMessage
context System.Web.HttpContext
return OAuthMessage
        /// <summary>
        /// This method parses the incoming request and creates an OAuth message from it.
        /// </summary>
        /// <param name="httpContext"> The current HttpContext.</param>
        /// <returns>Returns the OAuth message created from the incoming request.</returns>
        public virtual OAuthMessage ParseIncomingRequest(HttpContextBase httpContext)
        {
            if (TempData[OauthMessageKey] != null)
            {
                TempData.Keep(OauthMessageKey);
                return TempData[OauthMessageKey] as OAuthMessage;
            }

            var serializer = new OAuthMessageSerializer();
            var message = serializer.Read(httpContext);
            return message;
        }
        private void AuthorizeTwoLegged()
        {
            var authorizeCodeRequest = BuildAuthorizationCodeRequest();

            var serializer = new OAuthMessageSerializer();
            var encodedQueryFormat = serializer.GetFormEncodedQueryFormat(authorizeCodeRequest);

            HttpWebRequest httpWebRequest = WebRequest.Create(authorizeCodeRequest.BaseUri) as HttpWebRequest;
            httpWebRequest.Method = "POST";
            httpWebRequest.ContentType = "application/x-www-form-urlencoded";
            StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream());
            streamWriter.Write(encodedQueryFormat);
            streamWriter.Close();

            try
            {
                var message = serializer.Read(httpWebRequest.GetResponse() as HttpWebResponse) as EndUserAuthorizationResponse;
                if (message != null)
                {
                    AuthorizeWithACS(message.Code);
                }
            }
            catch (WebException webex)
            {
                var message = serializer.Read(webex.Response as HttpWebResponse);

                var endUserAuthorizationFailedResponse = message as EndUserAuthorizationFailedResponse;
                if (endUserAuthorizationFailedResponse != null)
                {
                    throw new AuthenticationException(endUserAuthorizationFailedResponse.ErrorDescription);
                }

                var userAuthorizationFailedResponse = message as ResourceAccessFailureResponse;
                if (userAuthorizationFailedResponse != null)
                {
                    throw new AuthenticationException(userAuthorizationFailedResponse.ErrorDescription);
                }

                throw;
            }
        }
        /// <summary>
        /// Authorizes the specified refresh token.
        /// </summary>
        /// <param name="refreshToken">The refresh token.</param>
        public void Authorize(string refreshToken)
        {
            var authorizeRequest = BuildAccessTokenRequest(refreshToken);

            var serializer = new OAuthMessageSerializer();
            var encodedQueryFormat = serializer.GetFormEncodedQueryFormat(authorizeRequest);

            HttpWebRequest httpWebRequest = WebRequest.Create(authorizeRequest.BaseUri) as HttpWebRequest;
            httpWebRequest.Method = "POST";
            httpWebRequest.ContentType = "application/x-www-form-urlencoded";
            StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream());
            streamWriter.Write(encodedQueryFormat);
            streamWriter.Close();

            try
            {
                var message = serializer.Read(httpWebRequest.GetResponse() as HttpWebResponse) as AccessTokenResponse;
                if (message != null)
                {
                    CurrentAccessToken = message;
                    LastAccessTokenRefresh = DateTime.UtcNow;
                }
            }
            catch (WebException webex)
            {
                var message = serializer.Read(webex.Response as HttpWebResponse);

                var endUserAuthorizationFailedResponse = message as EndUserAuthorizationFailedResponse;
                if (endUserAuthorizationFailedResponse != null)
                {
                    throw new AuthenticationException(endUserAuthorizationFailedResponse.ErrorDescription);
                }

                var userAuthorizationFailedResponse = message as ResourceAccessFailureResponse;
                if (userAuthorizationFailedResponse != null)
                {
                    throw new AuthenticationException(userAuthorizationFailedResponse.ErrorDescription);
                }

                throw;
            }
        }