You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用firebase-admin发布非us-central1区域Eventarc事件报403错误

问题说明

使用firebase-admin/eventarc直接向us-central1以外区域的Eventarc发布事件时操作失败,返回权限错误;将通道配置的区域参数替换为us-central1后,事件发布可正常执行,需确认该现象是否属于Eventarc Publishing API的功能限制。

发布事件所用代码

const allowedEventTypes = ["eu.testing.v1.test"];
const eventarcChannel = `projects/${process.env.GCLOUD_PROJECT}/locations/europe-west1/channels/my-channel`;
const eventChannel = getEventarc().channel(eventarcChannel, {
  allowedEventTypes: allowedEventTypes,
});
const eventType = "test";
const data = {
    testData: "1234",
};
await eventChannel?.publish({
    type: `eu.testing.v1.${eventType}`,
    data: data,
    source: "testing.eu",
});

报错信息

Error while publishing event PrefixedFirebaseError: Unexpected response with status: 403 and body: {
  "error": {
    "code": 403,
    "message": "Read access to project <project-name> was denied",
    "status": "PERMISSION_DENIED"
  }
}
问题解答

该现象不属于Eventarc Publishing API的功能限制,问题根源是firebase-admin/eventarc SDK的默认配置逻辑:

  • SDK初始化时默认绑定us-central1区域的全局服务鉴权上下文,调用非us-central1区域的Eventarc通道时,不会自动适配对应区域的鉴权规则,因此触发权限拒绝报错。
  • 修复方式:
    • 初始化Eventarc客户端实例时,显式指定目标区域对应的服务端点
    • 确认当前调用使用的服务账号,已被授予目标区域Eventarc通道的roles/eventarc.eventPublisher权限,具备对应区域的事件发布资格

内容的提问来源于stack exchange,提问作者Sélène Aernout

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.31 23:00:55