[英]Why isn't context.auth appearing in the context:EventContext parameter on the Firebase function onCreate document trigger?
Problem: The optional context.auth.uid is expected to be part of the parameters of a firebase trigger, but is not being provided.问题:可选的 context.auth.uid 应该是 firebase 触发器参数的一部分,但没有提供。
I am writing a document onCreate trigger on Firebase Cloud Functions.我正在 Firebase Cloud Functions 上编写文档 onCreate 触发器。 This trigger will write a sub-collection document using some of the data from the triggering document and the UID of the user who created it.此触发器将使用触发文档中的一些数据和创建它的用户的 UID 编写子集合文档。
A standard trigger function will accept the following标准触发函数将接受以下内容
export const onCreateUnit = functions.firestore.document('/units/{unitId}').onCreate((snap, context) => {
https://firebase.google.com/docs/reference/functions/providers_firestore.documentbuilder.html#oncreate https://firebase.google.com/docs/reference/functions/providers_firestore.documentbuilder.html#oncreate
The context object should include an auth object which would contain the uid and token上下文对象应包含一个身份验证对象,该对象将包含 uid 和令牌
context: {
...contextProperties,
auth: {
uid: XXXXXX-XXXX-XXXX,
token: YYYYYYYYYYY
}
}
Some things to keep in mind.有些事情要记住。
Why is there no auth property provided in the context?为什么上下文中没有提供 auth 属性? How can I fix it?我该如何解决?
看起来您没有提供从前端到在一起的数据,请检查您的用户是否已经登录,这发生在我身上几次。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.