Node.js GoogleCloudFunctions(GCF)在本地使用身份验证头运行良好,但在部署时返回401

Node.js GoogleCloudFunctions(GCF)在本地使用身份验证头运行良好,但在部署时返回401,node.js,google-cloud-functions,gcloud,Node.js,Google Cloud Functions,Gcloud,我有一个函数,它有一些代码来检查用户是否经过身份验证 export const addAffiliate = functions.region('us-central1').https.onCall( async (inputData: any, context: functions.https.CallableContext) => { checkAuthentication(context); ... 为了测试它,我使用gcloud auth print iden

我有一个函数,它有一些代码来检查用户是否经过身份验证

export const addAffiliate = functions.region('us-central1').https.onCall(
  async (inputData: any, context: functions.https.CallableContext) => {
    checkAuthentication(context);
    ...
为了测试它,我使用
gcloud auth print identity token
命令生成令牌,将其粘贴到带有“Bearer”+令牌值的授权头中,并调用它以获得成功响应。

然而,当我部署函数时,它甚至没有到达
checkAuthentication
方法。它只是立即返回未经验证的响应(401)。我没有提供身份验证头的工作流工作正常,我得到了预期的400。只有在向auth头中提供一些垃圾值时,我才能在本地复制这种行为

{
    "error": {
        "message": "Unauthenticated",
        "status": "UNAUTHENTICATED"
    }
}
函数使用服务帐户凭据进行初始化。在部署的功能中,列出了其权限和我的帐户。部署的函数无法读取id令牌的原因可能是什么?

找不到任何引用,但看起来只有firebase身份验证在这两种情况下都有效(本地和远程)。在我的情况下,我不应该使用google帐户id令牌,而是使用firebase用户id令牌,该令牌将google帐户链接为外部提供商帐户

{
    "error": {
        "message": "Unauthenticated",
        "status": "UNAUTHENTICATED"
    }
}