title: Firebase Auth -> user created with signInWithCustomToken has no email address
body: <p>I am using Firebase Custom Authentication System for a mobile app made with Ionic and I use Laravel 5.2 as a custom Auth back-end.</p>
  
  <p>When new user is registered I generate a token in laravel (using firebase/php-jwt) and return it to the mobile app.</p>
  
  <p>During this register process the app receive the token and create a user on firebase using the following code:</p>
  
  <pre><code>firebase.auth().signInWithCustomToken($auth.getToken())
      .then(function(response) {
          $log.debug(response);
      })
      .catch(function(error) {
          $log.debug(error.code + ' - ' + error.message);
      });
  </code></pre>
  
  <p>On back-end I use the code below to generate the token:</p>
  
  <pre><code>private function create_custom_token($uid, $email, $is_premium_account) {
      $service_account_email = env('SERVICE_ACCOUNT_EMAIL'); 
      $private_key = env('SERVICE_PRIVATE_KEY');
  
      $now_seconds = time();
      $payload = array(
          "iss" =&gt; $service_account_email,
          "sub" =&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; $uid,
          "claims" =&gt; array(
              "premium_account" =&gt; $is_premium_account,
              "email" =&gt; $email,
          )
      );
      return JWT::encode($payload, $private_key, "RS256");
  }
  </code></pre>
  
  <p>As you can see on the image below the user is generated on firebase but the problem is that it has no email address, only a UID.</p>
  
  <p><a href="https://i.stack.imgur.com/25Z8u.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/25Z8u.jpg" alt="enter image description here"></a></p>
  
  <p>It will be much better to have the email address in order to easily identify users.</p>
  
  <p>Maybe someone cane help. Thanks!</p>
  
  <p><strong>Updates:</strong></p>
  
  <p>I changed a little bit the $payload for the create_custom_token function:</p>
  
  <pre><code>  $payload = array(
        "iss" =&gt; $service_account_email,
        "sub" =&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; $uid,
        "email" =&gt; $email,
        "email_verified"          =&gt; false,
        "claims" =&gt; array(
          "premium_account" =&gt; $is_premium_account,
          "email" =&gt; $email,
          "email_verified"          =&gt; false,
        )
      );
  </code></pre>
  
  <p>and I also made some test to see it the token passed to firebase contains all the needed data. I decoded the encoded token with the same library (firabase/php-jwt) on my back-end and seams to be OK but firebase still create the user without email address.</p>
  
  <p><a href="https://i.stack.imgur.com/rw5wn.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/rw5wn.jpg" alt="enter image description here"></a> </p>
  
  <p>I don't know what I am missing :(</p>