Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update new API key on current firebase project

For some reason, my firebase project apikey associate with database changed. I can still create another api key, update into the application.

But when user try to reset password, the link use the old key and lead to "Your request to reset your password has expired or the link has already been used" (I think I read this problem somewhere and now I found the reason).

Is there anyway to update new api key for an existing firebase project?

Thank you

like image 732
Hieu Nguyen Avatar asked Sep 17 '16 16:09

Hieu Nguyen


1 Answers

Somehow, my original apiKey was recovered. You can find the original key (which were deleted from console.google.com) associated with the application on the main firebase page, through

Overview > Project settings > GENERAL

Basically, when users requested to recover the password, firebase will send an email with recovery link. If you have a look at the link, you will see the API included in the link is the one that no longer exists.

I recommend you to contact firebase support. I don't have an official way to solve the issue but here is quick I can think of, following as

  1. Create new API at console.google.com > choose your firebase project
  2. Create a page with a function that can read URL parameters. Make it receive firebase recovery password URL and replace dead API with new one, then redirect you to new firebase recovery password URL
  3. Edit email template by adding the page you created on step 2, with firebase recovery full URL as a parameter

To be more accurate, here is an example. I have my project called "MyFirebaseProj", my domain is "example.com"

  1. I go to console.google.com, choose "MyFirebaseProj", on API Manager panel, choose Credentials > Credentials. Click on Create credentials > API Key. So I got a new API key call "MyNewLongAPI".
  2. I created a recover-password.html password and have this javascript function https://codepen.io/hieunc229/pen/mWwVbv (this one will read the firebase url, get oobCode and generate new URL). Edit the javascript so it will redirect the user to new URL. Upload this one into my host (mydomain.org/recover-password.html)
  3. On Firebase console, Authentication > Email Template > Reset Password. Change the link to something like

<a href='http://example.com/recover-password.html?url=%LINK%'>%LINK%</a>

Then save it

Now when user go into your recover password page, they will be redirected into firebase url with new API and it should works

Hope it helps!

like image 104
Hieu Nguyen Avatar answered Jan 03 '23 04:01

Hieu Nguyen