Search code examples
firebasegoogle-cloud-platformfirebase-authenticationgoogle-oauth

Firebase Authentication unable to enable Google auth method - "Error updating Google"


I am trying to enable the Firebase authentication with the Google Auth sign-in method, but enabling it and clicking "save" shows the error "Error updating Google".

In the Google Cloud Console activity logs, it shows:

Failed:google.internal.firebase.v1.FirebaseInternalProductService.EnableGoogleSignIn

With the error message "Not found (HTTP 404): Operation failed with error code NOT_FOUND."

However, when I tried this in a new Google Cloud project, it worked perfectly. I have tried removing and recreating the Firebase Admin SDK, removing and creating a new app, and removing the OAuth credentials. I cannot seem to find any solution to this problem other than creating a new project, but I would prefer to keep my existing project ID.

Alternatively, if there is any way to reset my GCP project or remake it with the same ID, that would also be fine.


Solution

  • This issue is caused by deleting the OAuth client autogenerated by Firebase by default.

    To solve it, you need to first create a new OAuth 2 client ID, and set the necessary redirect URIs for your Firebase app (they should default to something like https://{PROJECT_ID}.web.app/__/auth/handler).

    Then, call this API - the request should look something like this, using the client ID and client secret from the credentials generated above:

    PATCH https://identitytoolkit.googleapis.com/admin/v2/projects/{PROJECT_ID}/defaultSupportedIdpConfigs/google.com

    {
      "name": "projects/{PROJECT_ID}/defaultSupportedIdpConfigs/google.com",
      "enabled": true,
      "clientId": "{YOUR_CLIENT_ID}",
      "clientSecret": "{YOUR_CLIENT_SECRET}"
    }
    

    After making this API call, the Google authentication provider should be enabled.