I currently have 2 firebase/google cloud projects. One for frontend and one for backend where app engine is hosted. I wanted to use firebase to send push notifications from the FCM token.
The code that I am using is the following:
Firebase.app = admin.initializeApp();
What this does is that it uses my backends firebase project not the firebase project of my frontend. To connect to a different project's firebase I will have to do the following to my knowledge:
Firebase.app = admin.initializeApp({
credential: admin.credential.applicationDefault(),
});
And I will need to have an environment variable named GOOGLE_APPLICATION_CREDENTIALS
which will have to point to a google-credentials.json
file containing the JSON object with the google credentials of the different applications.
I don't upload my google credentials json file as I am using cloud build from my Github.
I was trying the following approach:
Create a Base64 string of the json object and store it in a variable and then create a json file from the decoded base64 string and then point to the GOOGLE_APPLICATION_CREDENTIALS
to the created file. But the google app engine does not allow for writing to files, so this is a dead-end unless there is something that will allow me to write to a file.
Is there some way I can link the firebase project of the frontend to the google cloud project of my backend so that the google cloud project directly links up the frontend's firebase project. If not then is there a way in which I can migrate the firebase project easily from the frontend firebase project to the backend firebase project?
Any suggestion would be a great help. Thanks!
CodePudding user response:
There is no direct way to migrate the Firebase Application from one project to another project. You can refer to this stackoverflow thread to find this. Also there is no way to migrate an App Engine application from one project to another. Instead you have to deploy the App Engine application in the new project.
So your concern narrows down to the fact that which one will be easier for you. I would suggest deploying the App Engine application in the same project where your Firebase frontend is already present. Because it seems easier as you only have to change the default project configuration in your SDK or Command Line Interface and follow this documentation.