title: Access Token in Firebase REST request not working
body: <p>I'm having some issues doing an authenticated request to Firebase.</p>
  
  <p>I have a token generated but when I send it to Firebase I always get an <code>Unauthorized request.</code> response when I send the <code>access_token</code> in the request. The strange part is that it works without the param.</p>
  
  <p>I even tested with no access rules, but I get the same result.</p>
  
  <p>When I send <code>curl 'https://&lt;PROJECTID&gt;.firebaseio.com/events.json'</code> I get the expect values back, but if I send <code>curl 'https://&lt;PROJECTID&gt;.firebaseio.com/events.json?access_token=&lt;TOKEN&gt;'</code> the answer is 
  <code>{ "error" : "Unauthorized request." }</code></p>
  
  <p>I've tried sending it in the header like <code>curl -H "Authorization: Bearer &lt;TOKEN&gt;" https://&lt;PROJECTID&gt;.firebaseio.com/events.json</code> but does not work either.</p>
  
  <p>If I enforce some rules in the database the initial request with no token gives me
  <code>{ "error" : "Permission denied" }</code> but I still get <code>{ "error" : "Unauthorized request." }</code> if I send the token.</p>
  
  <p>Any help would be much appreciated.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Managed to fix it. I was not getting the token properly. After checking <a href="https://stackoverflow.com/questions/40810233/cant-access-firebase-database-via-http-rest-error-403-forbidden">this thread</a> I noticed I was not sending <code>https://www.googleapis.com/auth/userinfo.email</code> in the <code>scopes</code> array when doing the request for the token. After adding it works fine.</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>As mentioned by Xin Meng this is pretty clear in the <a href="https://firebase.google.com/docs/database/rest/auth" rel="noreferrer" title="Authenticate REST Requests documentation">Firebase Authenticate REST Requests documentation</a> as well.</p>