Skip to content

How firebase config get's pulled? #174

@avocadoslab

Description

@avocadoslab

Version info

firebase-functions: 0.8.1

firebase-tools: 3.17.3

firebase-admin: 5.8.1

Were you able to successfully deploy your functions?

Yes.

Question

I have two firebase projects. (Project1 and Project2)

I'm using Service Account info from Project1 into Project2 as I need access to Auth data which resides in Project1. Remote config for Project2 looks as follows:

{
    "service_account": {
        "private_key": "<project1-private-key>",
        "email": "<project1-email>",
        "project_id": "<project1-project-id>"
    }
}

Initializing Project2 as follows

const config = functions.config();
const fbConfig = functions.config().firebase;

fbConfig.credential = admin.credential.cert({
    'private_key': replace(get(config, 'service_account.private_key'), /\\n/g, '\n')),
    'client_email': get(config, 'service_account.email'),
    'project_id': get(config, 'service_account.project_id')
});

admin.initializeApp(fbConfig);

When I do

const fbConfig = functions.config().firebase

It returns firebase info which belongs to Project1.

"firebase": {
        "apiKey": "<project1-api-key>",
        "authDomain": "<project1-auth-domain>",
        "databaseURL": "<project1-database-url>",
        "projectId": "<project1-project-id>",
        "storageBucket": "<project1-storage-bucket>",
        "messagingSenderId": "<project1-sender-id>"
    }

Trying to wrap my head around few questions.

  1. How it knows to pull firebase details about Project1?

  2. Is there a connection between service account used & firebase details which gets pulled? Service account key is the only place where I'm referencing about Project1 in my entire Project2 codebase.

  3. When I do firebase functions:config:get locally, I only get service_account info in response. Response doesn't have any firebase info in it. Why it doesn't have firebase details?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions