title: Authorization in RESTful HTTP API, 401 WWW-Authenticate
body: <p>I'm creating a RESTful service to provide data to a web application. I have two related questions about this.</p>
  
  <h1>1. How to deal with unauthorized requests?</h1>
  
  <p>I'm intending to respond to requests with the following codes:</p>
  
  <ul>
  <li>Is the resource open and found? <strong>200 OK</strong></li>
  <li>Do you need to be authenticated to access the resources? <strong>401 Unauthorized</strong></li>
  <li>Don't you have access to a category of resources? <strong>403 Forbidden</strong></li>
  <li>Do you have access to a category of resources, but not to this specific resource? <strong>404 Not Found</strong> to prevent people from getting to know the existance of a resource they do not have access to.</li>
  <li>Doesn't the resource exist? <strong>404 Not Found</strong></li>
  </ul>
  
  <p>Is this a recommended way for a RESTful service to behave?</p>
  
  <h1>2. What <code>WWW-Authenticate</code> header should 401 responses supply?</h1>
  
  <p>I read on <a href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error" rel="noreferrer">Wikipedia</a> (probably not the most accurate resource, but it works for me) that a 401 response <em>must</em> include a <code>WWW-Authenticate</code> header, however upon further searching I couldn't really find any resource that stated what this value means and what it should be.</p>
  
  <p>I found several SO questions and forum topics about this header and they all seem to be about OAuth, suggest against using 401 status codes or say you can just make something up.</p>
  
  <p>What is the correct value this header should contain?</p>