gpt4 book ai didi

firebase - 在使用 firestore 权限的 native 应用程序(通过 Expo)中 - request.auth 始终为 null

转载 作者:行者123 更新时间:2023-12-04 01:08:02 25 4
gpt4 key购买 nike

这是我的代码:

firebase.auth().onAuthStateChanged((user) => {
if (user) {
console.log("We are authenticated now!");
firebase.firestore().collection("users")
.doc(firebase.auth().currentUser.uid).set({ name: "new name" });
} else {
loginWithFacebook();
}
});

而且,这是我的许可规则:
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read, write: if request.auth != null;
}
}
}

似乎无论如何,request.auth 始终为空。
我得到的错误:

Firestore (4.8.0) 2017-12-20T04:18:27.321Z [Connection]: WebChannel received error: {"code":403,"message":"Missing or insufficient permissions.","status":"PERMISSION_DENIED"}

最佳答案

当我在 Expo 上遇到最新的 Firebase JS SDK 问题时,我降级到 Firebase SDK 4.6.2。

此外,您必须这样做才能使一切正常工作:

复制 https://gist.githubusercontent.com/mikelehen/444950a35019208f3aaf18d37ab4937c/raw/85ac4cb3108d92163cb8f04fbdddcc88d4081aab/index.js

在您的 node_modules/@firebase/webchannel-wrapper/dist/index.js
没有这个,你将不会从你的收藏中得到任何东西。

希望这可以帮助。

关于firebase - 在使用 firestore 权限的 native 应用程序(通过 Expo)中 - request.auth 始终为 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47859246/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com