title: How do I access my Firebase Database via HTTP REST API?
body: <p>Thanks to <a href="https://stackoverflow.com/a/37419212/3600300">this answer</a> I am able to connect to Firebase 3 via HTTP REST API and an email/password. Logging in with this API returns an access token that is used to access the Firebase Database. This access token expires after 1 hour. A refresh token is also returned after logging in, which I can use to refresh my access token. Here is what I am doing specifically:</p>
  
  <p>Method:</p>
  
  <pre><code>POST
  </code></pre>
  
  <p>URL:</p>
  
  <pre><code>https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=&lt;my-firebase-api-key&gt;
  </code></pre>
  
  <p>Payload:</p>
  
  <pre><code>{
      email: "&lt;email&gt;",
      password: "&lt;password&gt;",
      returnSecureToken: true
  }
  </code></pre>
  
  <p>Response:</p>
  
  <pre><code>{
      "kind": "identitytoolkit#VerifyPasswordResponse",
      "localId": "&lt;firebase-user-id&gt;", // Use this to uniquely identify users
      "email": "&lt;email&gt;",
      "displayName": "",
      "idToken": "&lt;provider-id-token&gt;", // Use this as the auth token in database requests
      "registered": true,
      "refreshToken": "&lt;refresh-token&gt;",
      "expiresIn": "3600"
  }
  </code></pre>
  
  <p>In the case of refreshing my access token:</p>
  
  <p>URL: </p>
  
  <pre><code>https://securetoken.googleapis.com/v1/token?key=&lt;my-firebase-api-key&gt;
  </code></pre>
  
  <p>Payload:</p>
  
  <pre><code>{
      grant_type: "refresh_token",
      refresh_token: "&lt;refresh-token&gt;"
  }
  </code></pre>
  
  <p>Response:</p>
  
  <pre><code>{
    "access_token": "&lt;access-token&gt;",
    "expires_in": "3600",
    "token_type": "Bearer",
    "refresh_token": "&lt;refresh-token&gt;",
    "id_token": "&lt;id-token&gt;",
    "user_id": "&lt;user-id&gt;",
    "project_id": "&lt;project-id&gt;"
  }
  </code></pre>
  
  <p><strong>How do I access my database via HTTP REST API given that I have my access token?</strong></p>