title: Logging in users through Azure AD
body: <p>I have a website which allows admin users to connect to their Office 365 account.  From this I can read the calendars of all users and also get a user list.  This all works fine.</p>
  
  <p>The user rights that I ask are:</p>
  
  <pre><code>Sign users in  
  Read calendars in all mailboxes  
  Read directory data  
  Read all users' full profiles  
  Sign in and read user profile  
  Enable sign-on and read users' profiles  
  Read directory data  
  </code></pre>
  
  <p>And these are the scopes: ["openid", "Calendars.Read", "User.Read", "User.Read.All", "offline_access"]</p>
  
  <p>Getting all the users works fine with this call:
      <a href="https://graph.microsoft.com/v1.0/users" rel="nofollow">https://graph.microsoft.com/v1.0/users</a></p>
  
  <p>However now I want to enhance the features so users are logged in automatically.  So all I need is a call to get the current profile of the user so I can match the ID with the ID's in the application...  I found this call and tried executing it:
  <a href="https://graph.microsoft.com/v1.0/me" rel="nofollow">https://graph.microsoft.com/v1.0/me</a></p>
  
  <p>But I'm getting back this:</p>
  
  <p>784: unexpected token at '{
    "error": {
      "code": "Request_ResourceNotFound",
      "message": "Resource 'a6787ee0-4ba1-421f-a19c-beadf693b9eb' does not exist or one of its queried reference-property objects are not present.",
      "innerError": {
        "request-id": "c767c4ee-0912-4744-a7e4-59a8a23626fe",
        "date": "2016-10-22T01:26:54"
      }
    }
  }'</p>
  
  <p>What am I missing here?</p>
  
  <p>Just to make sure, can somebody confirm that what I plan to do is possible:</p>
  
  <ul>
  <li>Have the admin user authenticate and give access (see rights above)</li>
  <li>Sync the users so they exist in my webapp as well (and I have their ID's)</li>
  <li>When another user is already signed in to MS, I want to detect this when they go to my webpage and sign him in as well in my webapp</li>
  </ul>