I have two firebase projects (default and staging). Both are initialised under the same aliases in the CLI.
I can deploy everything successfully to 'default' and all but functions successfully to 'staging'. I get a 403 error when deploying to staging.
I initialise my firebase admin using the following code, that uses my Service Account key.json file, so I can run my functions locally.
// Import from Firebase
import * as functions from 'firebase-functions'
import * as admin from 'firebase-admin'
// Admin Init that supports localhost testing
const serviceAccount = require('../keys/default-key.json')
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
})
If I manually change the reference to 'staging-key.json' which uses the Service Account key.json from my staging project, then the deploy to staging works fine too.
My question: Can I automatically change the referenced key.json file depending on the project I'm deploying too?
OR - is there a better way I should be managing this situation?
Ideally I just want to use 'firebase use' in CLI to switch between projects and deploy, without having to alter the code.