How to update new API key on current firebase project

丶灬走出姿态 提交于 2019-12-07 05:37:10

问题


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


回答1:


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!




回答2:


If anyone run into the same issue, as I get in touch with Firebase team and they are investigating about it. Currently there haven't been a way to help it.



来源:https://stackoverflow.com/questions/39549346/how-to-update-new-api-key-on-current-firebase-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!