当我的一个Firebase云功能被触发(云Firestore触发器)时,出现权限错误。我不确定如何解决此问题,相关资源很少。我已经包含了函数本身以及下面的错误。
我尝试过重新初始化应用程序,禁用和重新启用api以及删除和重新部署功能。
功能:
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
import {reportError} from "../logging";
import {chargeTypes} from "../constants/constants";
import {handleCreateTeam} from "./create-team";
import {handleJoinTeam} from "./join-team";
import {handleAcceptInvite} from "./accept-invite";
export async function handleNewJoinTeamDocument(event:
admin.firestore.DocumentSnapshot, context: functions.EventContext, db:
admin.firestore.Firestore) {
const todo = event.data();
if (todo === undefined) {
return reportError("Todo returned no data in handle new join team document", {user: context.params.id});
}
if (todo.processed) {
return {message: "Already processed this queue item"}
}
let result;
switch (todo.type) {
case chargeTypes.ACCEPT_INVITE:
result = handleAcceptInvite(todo, event, context, db);
break;
case chargeTypes.CREATE_TEAM:
result = handleCreateTeam(todo, event, context, db);
break;
case chargeTypes.JOIN_TEAM:
result = handleJoinTeam(todo, event, context, db);
break;
default:
break
}
return await result;
}
错误:
Error: 7 PERMISSION_DENIED: The caller does not have permission at
Object.exports.createStatusError
(/srv/node_modules/grpc/src/common.js:91:15) at
Object.onReceiveStatus
(/srv/node_modules/grpc/src/client_interceptors.js:1204:28) at
InterceptingListener._callNext
(/srv/node_modules/grpc/src/client_interceptors.js:568:42) at
InterceptingListener.onReceiveStatus
(/srv/node_modules/grpc/src/client_interceptors.js:618:8) at
callback
(/srv/node_modules/grpc/src/client_interceptors.js:845:24)
日志详细信息:
{
insertId: "000000-b7bc9521-25b8-4357-9301-a5c1df269ef4"
labels: {
execution_id: "767010698187131"
}
logName: "projects/snowballtesting-d70da/logs/cloudfunctions.googleapis.com%2Fcloud-functions"
receiveTimestamp: "2019-09-29T16:38:47.207554787Z"
resource: {
labels: {…}
type: "cloud_function"
}
severity: "ERROR"
textPayload: "Error: 7 PERMISSION_DENIED: The caller does not have permission
at Object.exports.createStatusError (/srv/node_modules/grpc/src/common.js:91:15)
at Object.onReceiveStatus (/srv/node_modules/grpc/src/client_interceptors.js:1204:28)
at InterceptingListener._callNext (/srv/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (/srv/node_modules/grpc/src/client_interceptors.js:618:8)
at callback (/srv/node_modules/grpc/src/client_interceptors.js:845:24)"
timestamp: "2019-09-29T16:38:45.946Z"
trace: "projects/snowballtesting-d70da/traces/daf59e0d15388a1c4500bb4a88a7a084"
}