title: Secure PHP REST API
body: <p>I am making a Social Networking website and I want to provide APIs for developers to use. So, I am thinking of using REST API for this. </p>
  
  <p>Now this question is not about how to create a REST API. That is well explained in many websites and SO questions.</p>
  
  <p><strong>My Question is:</strong>
  When I give a developer this API (lets say which can be used to get user info).</p>
  
  <p>Say USER 1 does not want his date of birth and email to be visible</p>
  
  <p>Say USER 2 does not want his mobile number to be visible</p>
  
  <p>Say USER 3 does not want anyone apart from his friends to see his info</p>
  
  <p>... and so on (each user have their own privacy setting which I have already stored in DB)</p>
  
  <p>Now, how do I authenticate properly to make sure:</p>
  
  <p>1) Developers will not be able to access User info when they have not authenticated the Application to use API to access their info</p>
  
  <p>2) Restrict Developers from accessing fields which has been set by the user as private</p>
  
  <p>Do I have to make separate DBs for this? Is there any easy, professional and secure way to do this?</p>