title: Rest client login for ASP.NET MVC 5 Web API2
body: <p>I have created mixed project <strong>ASP.NET MVC5 +  WebAPI 2 (.NET Framework 4.5.6).</strong> I have implemented correct working API controller.</p>
  
  <p>I would like to protect this controller with <code>[Authorize]</code> attribute.
  And I have to use <strong><em>MS Windowsw Service client</em></strong> to consume this API.</p>
  
  <p><strong>At the moment of connecting to WebAPI it gets redirecting to the login webpage.</strong></p>
  
  <p>Have I implement special login method <strong>at the API controler itself</strong> or at the <code>AccountController</code> of the website?</p>
  
  <p>As I see for the mixed proyect Visual Studio does not generate this code</p>
  
  <pre><code>OAuthOptions = new OAuthAuthorizationServerOptions
  {
     TokenEndpointPath = new PathString("/Token"),
     Provider = new ApplicationOAuthProvider(PublicClientId),
     AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
     AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
     // In production mode set AllowInsecureHttp = false
     AllowInsecureHttp = true
  };
  </code></pre>
  
  <p>And instead of it there is another one. </p>
  
  <p>How to avoid it so Windows Service can consume API?</p>
  
  <p>Thank you!</p>