title: Firebase custom authentication fails 400
body: <p>I'm trying to use custom authentication to authenticate users to firebase. Created jwt token as they guided in documentation. But after send the token I'm getting this response</p>
  
  <pre><code>firebase.auth().signInWithCustomToken(response.body).catch(function (error) {
                // Handle Errors here.
                console.log(error)
              })
  
  "error": {
    "errors": [
     {
      "domain": "global",
      "reason": "invalid",
      "message": "INVALID_CLAIMS"
     }
    ],
    "code": 400,
    "message": "INVALID_CLAIMS"
   }
  </code></pre>
  
  <p>Console</p>
  
  <blockquote>
    <p>code: "auth/internal-error", message:
    "{"error":{"errors":[{"domain":"global","reason":"i…CLAIMS"}],"code":400,"message":"INVALID_CLAIMS"}}"</p>
  </blockquote>
  
  <p>My jwt token is also in correct format.</p>
  
  <p>Php code use to generate jwt token</p>
  
  <pre><code>public function authFirebase() {
          $now_seconds = time();
          $payload = [
            "iss" =&gt; $this-&gt;service_account_email,
            "sub" =&gt; $this-&gt;service_account_email,
            "aud" =&gt; "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
            "iat" =&gt; $now_seconds,
            "exp" =&gt; $now_seconds+(60*60),  // Maximum expiration time is one hour
            "uid" =&gt; \Auth::user()-&gt;id,
            "claims" =&gt; array()
          ];
          return JWT::encode($payload, $this-&gt;private_key, "RS256");
      }
  </code></pre>