I can think of the following reasons why you are facing this error:
You have not created a Firebase app. You can create the app from Project Overview Page.
You have created the Firebase app but have not added your debug or release Keystore SHA1 Fingerprints
You can go to Project Overview -> Select App -> Settings -> General Tab and add those in the page down below:
You have not included the google-services.json file where it should be included
You can download that file from page showing in the screenshot above and include that in your project.
You have added SHA1 Fingerprints but have not enabled Google Authentication in Firebase.
Once you complete all the steps mentioned above, the error will disappear and your implementation will work properly. I recently fixed this with Ionic Version 6 with a capacitor Cordova. If you need help join us on our discord: https://discord.gg/VaJxEE2Q