Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase authentication - expired api key

i am developing a serverless client app that uses Firebase authentication and other services from Google. It was all working nicely, when suddely the FB login authentication stopped working. It happens that when try to login the user i obtain a 400 BADREQUEST with the following body:

{
    "error": {
        "code": 400,
        "message": "API key expired. Please renew the API key.",
        "errors": [{
            "message": "API key expired. Please renew the API key.",
            "domain": "global",
            "reason": "badRequest"
        }],
        "status": "INVALID_ARGUMENT"
    }
}

The url causing the problem is:

https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=AIzaSyDXJ1Lwo_Md0xZzFfPX9Y8dQWOaODE4uiM&cb=1534851951010

Some weird things:

  • i tested with totally different projects (so brand new keys): still failing
  • if i go to cloud console i found several unrestricted keys automatically created by Google (i attach a screenshot)

enter image description here

I also created a brand new app and executed it locally. Same outcome.

Any ideas ?

Add: i have just discovered that the Identity API is effectively returning me 100% failures at the moment.

enter image description here

like image 680
Bruno Ripa Avatar asked Aug 21 '18 11:08

Bruno Ripa


People also ask

How do I fix my expired API key?

Your API key is outdated. Go to Google API console, create a new public API key there and paste it to the "API Key For Your Firebase Dynamic Links Account" field on the plugin's settings page.

What does expired API key mean?

The API key provided by your Connect platform has expired. This occurs if your platform has either generated a new key or the connected account has been disconnected from the platform. Obtain your current API keys from the Dashboard and update your integration, or reach out to the user and reconnect the account.

What happens when Firebase token expires?

Firebase ID tokens are short lived and last for an hour; the refresh token can be used to retrieve new ID tokens. Refresh tokens expire only when one of the following occurs: The user is deleted. The user is disabled.


2 Answers

I was able to get this issue as well and this helped me solve my issue:

  1. Go to google api console and find the key: Android key (auto created by Google Service). These keys are automatically generated by Firebase when you choose the option: Email/password in authentication. Copy that key.

  2. Go to the google-services.json in your android studio under the projects section. Click on the file and look for the api_key -> current_key. Modify that value with the api key in step 1.

like image 193
Zandro Zulueta Avatar answered Sep 21 '22 15:09

Zandro Zulueta


First, go to https://console.firebase.google.com/

  1. Then choose the Android project

  2. Then go to SETTINGS of that project

  3. First, check that: sha1 and sha256 fingerprint are there for debug apk (Necessary) and release apk (necessary if you create a signed apk)

  4. There you will see a download JSON file button, click on it, and download the file.

  5. Then go to Android Studio and OPEN your project.

  6. Then on the left side menu, click the project subfile then find the googleservices.json file.

  7. Open that file by double-clicking it

  8. Now open the downloaded file, googleservices.json, and open it in notepad.

  9. Now copy all the content, just select all, and copy.

  10. Now go to the Android Studio, and right-click on the Google services file (in IntelliJ) and click compare with the clipboard and carefully accept all the differences into the Android Studio file.

  11. Or you can directly remove all the content and paste the copied into the Android Studio JSON file.

DONE! NOTE: Make sure you make a copy of the file before doing this.

like image 45
Vijay Avatar answered Sep 21 '22 15:09

Vijay