While developing my web application with the electron framework, I integrated Firebase-auth for user authentication. Following the Firebase guide, I generated an API key through project settings and inserted it into the body of my HTML document. However, upon opening the page in a browser, I encountered the following error message in the console:
code: "auth/invalid-api-key"
message: "Your API key is invalid, please check you have copied it correctly."
__proto__: Error
The bottom section of the HTML body contains the following script:
<script src="https://www.gstatic.com/firebasejs/5.8.2/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyAXXXXXXXXXXXXXXXXXXXXjILO32ZDxRKY",
authDomain: "jumbleup-773da.firebaseapp.com",
databaseURL: "https://jumbleup-773da.firebaseio.com",
projectId: "jumbleup-773da",
storageBucket: "jumbleup-773da.appspot.com",
messagingSenderId: "971123072180"
};
firebase.initializeApp(config);
</script>
Note: For security reasons, I replaced 20 digits of the real API key with X characters.