title: Firebase Authentication EmailAuthProvider: linking an anonymous user with a credential fails with expired token
body: <p>I am using firebase authentication with anonymous users.  When the user sign up on the site, we link their credential.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>//Create the email and password credential, to upgrade the anonymous user.    
  let credential = firebase.auth.EmailAuthProvider.credential(email, visitorId);
  
  //Link the credential to the currently signed in user (the anonymous user).
  auth.currentUser.link(credential).then((user) =&gt; {
  
       console.log("anonymous visitor successfully upgraded");
  
      }, 
  
      (error) =&gt; {
  
          //error upgrading the anonymouse user
          console.log("Error upgrading anonymous visitor", error);
  });
  </code></pre>
  
  <p><a href="https://firebase.google.com/docs/auth/web/anonymous-auth#convert-an-anonymous-account-to-a-permanent-account" rel="nofollow noreferrer">Here is documentation of this approach</a></p>
  
  <p>This has been working great until today.  Now I am suddenly receiving an error code: auth/network-request-failed.</p>
  
  <p>If I inspect the failed request in Fiddler, I find a response of:</p>
  
  <pre><code>{
   "error": {
    "errors": [
     {
      "domain": "global",
      "reason": "invalid",
      "message": "TOKEN_EXPIRED"
     }
    ],
    "code": 400,
    "message": "TOKEN_EXPIRED"
   }
  </code></pre>
  
  <p>}</p>
  
  <p>The odd thing is that if I decode the token on the request, the expiration date falls in the future (about 1 hour ahead which is the default time length for their tokens).  There is almost no delay between the time I generate the token, and the time I try linking it to the user.  So why the failure?</p>
  
  <p>My research:</p>
  
  <p><a href="https://github.com/angular/angularfire2/issues/581" rel="nofollow noreferrer">The issue here sounds similar, but I has not resolved it for me.</a></p>