Skip to content

HttpAgent can not work when serviceAccountPathOrObject parameter is a object in admin.credential.cert() #2960

Open

Description

@FTD-YI

Problem

When calling admin.credential.cert(), and the serviceAccountPathOrObject parameter is a object, not a file path, the http proxy agent can not work.

Environment

  • Operating System version: Red Hat Enterprice Linux 8.10
  • Firebase SDK version: 13.4.0
  • Firebase Product: message
  • Node.js version: 22.11.0
  • NPM version: 10.9.0

Steps to reproduce:

#### Relevant Code:

import * as admin from "firebase-admin";
import {readFilesync }from "fs";
import * as https from "https",

const serviceAccount = JSON.parse(readFilesync("./serviceAccount.json", "utf8"))
const proxyAgent = new https.Agent({
  host:"xxx",
  port: 8080,
  keepAlive: true,
  rejectUnauthorized: false,
});
const client= admin.initializeApp({
  credential:admin.credential.cert(
    {
      clientEmail: serviceAccount.client_email,
      privatekey: serviceAccount.private_key,
      projectId: serviceAccount.project_id,
    },// when serviceAccount is a object, it will raise the "app/invalid-credential" error
    // "./serviceAccount.json", when serviceAccount is a file path, can work
    proxyAgent
  ),
  httpAgent: proxyAgent, 
});

Activity

  1. google-oss-bot commented on Aug 25, 2025

    @google-oss-bot

    I found a few problems with this issue:

    • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
    • This issue does not seem to follow the issue template. Make sure you provide all the required information.
  2. FTD-YI commented on Aug 25, 2025

    @FTD-YI
    Author

    Raise a PR to solve this issue, #2961, please review.

  3. self-assigned this
    on Nov 4, 2025
  4. added theissue type on Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions