title: Getting HttpRequest extension method written for MVC to work in Web Api
body: <p>I'm working with OAuth 2.0 for MVC, a .NET library for Oauth2. I'm building a Web Api project, however, and am hoping to get this library to work with Web Api. </p>
  
  <p>The problem I'm running into is that the library uses two extension methods on the HttpRequestBase that it calls from the controller. </p>
  
  <p>Here are the extension methods:</p>
  
  <pre><code>public static string GetToken(this HttpRequest request)
      {
          var wrapper = new HttpRequestWrapper(request);
          return GetToken(wrapper);
      }
  
      public static string GetToken(this HttpRequestBase request)
      {
          if (request == null)
              return String.Empty;
  
          // Find Header
          var headerText = request.Headers[OAuthConstants.AuthorzationHeader];
          if (!String.IsNullOrEmpty(headerText))
          {
              var header = new AuthorizationHeader(headerText);
              if (string.Equals(header.Scheme, "OAuth", StringComparison.OrdinalIgnoreCase))
                  return header.ParameterText.Trim();
          }
  
          // Find Clean Param
          var token = request.Params[OAuthConstants.AuthorzationParam];
          return !String.IsNullOrEmpty(token)
              ? token.Trim()
              : String.Empty;
      }
  </code></pre>
  
  <p>In the MVC project, they simply call Request.GetToken() from the controller. Of course, Web Api's request is an HttpRequestMessage. I'm afraid addressing the difference between HttpRequest and HttpRequest message is beyond my capabilities right now. </p>
  
  <p>Can I convert this extension method to work with HttpRequestMessage or somehow make it work in Web Api??</p>
  
  <p>Thanks!</p>