Home > Mobile >  How to get firebase token and uid from OOBCODE?
How to get firebase token and uid from OOBCODE?

Time:10-08

We are sending firebase email verification link to user. After clicking on that, we have created custom page to verify the user.

All is working fine till now.

Now, after verify email, we are in logged out mode and we want to call the custom API with firebase ID and token.

We have OOBCODE in url, So can we get the firebase uid and token using OOBCODE?

Below is the code:

if(router.query.oobCode)
{
  firebase.auth().applyActionCode(router.query.oobCode)
  .then((res) => {
    setValidCode(true)
    setVerifiedCode(true)
  }, 
  error => 
  {
    setError(error.message)
    setValidCode(false)
    setVerifiedCode(true)
  });
}

CodePudding user response:

The applyActionCode() method only confirms that the email was successfully verified, nothing else. It just confirms that the verification email that was sent to the email address was opened, confirming that the email owner is the correct user. In particular, it doesn't log in the user to your app.

From there, it's up to you to implement the desired flow. You can redirect to a login page. You could also use the apiKey query string parameter that is present in the URL: it is the Firebase project's API key.

  • Related