gpt4 book ai didi

android - Firebase 身份验证有效,但 firestore 拒绝请求,因为权限缺失或不足

转载 作者:行者123 更新时间:2023-12-05 00:04:22 38 4
gpt4 key购买 nike

过去几个月我有一个安卓应用在运行。我昨天升级到 Blaze 计划,从那时起 Firestore 开始拒绝请求并出现以下错误(不确定这两个是否相关并且我远远低于我的配额)

PERMISSION_DENIED: Missing or insufficient permissions.

以下是我的安全规则

service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth.uid != null;
}
}
}

Firebase 身份验证在我使用时工作正常

fbUser = firebaseAuth.getCurrentUser();

我正在获取 fbUser。但是我的 Android 应用程序对 Firestore 的任何请求都被拒绝了。以下是堆栈跟踪

com.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions.
at com.google.firebase.firestore.util.Util.exceptionFromStatus(com.google.firebase:firebase-firestore@@21.4.3:117)
at com.google.firebase.firestore.core.EventManager.onError(com.google.firebase:firebase-firestore@@21.4.3:166)
at com.google.firebase.firestore.core.SyncEngine.removeAndCleanupTarget(com.google.firebase:firebase-firestore@@21.4.3:534)
at com.google.firebase.firestore.core.SyncEngine.handleRejectedListen(com.google.firebase:firebase-firestore@@21.4.3:418)
at com.google.firebase.firestore.core.FirestoreClient.handleRejectedListen(com.google.firebase:firebase-firestore@@21.4.3:317)
at com.google.firebase.firestore.remote.RemoteStore.processTargetError(com.google.firebase:firebase-firestore@@21.4.3:557)
at com.google.firebase.firestore.remote.RemoteStore.handleWatchChange(com.google.firebase:firebase-firestore@@21.4.3:441)
at com.google.firebase.firestore.remote.RemoteStore.access$100(com.google.firebase:firebase-firestore@@21.4.3:53)
at com.google.firebase.firestore.remote.RemoteStore$1.onWatchChange(com.google.firebase:firebase-firestore@@21.4.3:176)
at com.google.firebase.firestore.remote.WatchStream.onNext(com.google.firebase:firebase-firestore@@21.4.3:108)
at com.google.firebase.firestore.remote.WatchStream.onNext(com.google.firebase:firebase-firestore@@21.4.3:38)
at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.lambda$onNext$1(com.google.firebase:firebase-firestore@@21.4.3:119)
at com.google.firebase.firestore.remote.AbstractStream$StreamObserver$$Lambda$2.run(Unknown Source:4)
at com.google.firebase.firestore.remote.AbstractStream$CloseGuardedRunner.run(com.google.firebase:firebase-firestore@@21.4.3:67)
at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.onNext(com.google.firebase:firebase-firestore@@21.4.3:110)
at com.google.firebase.firestore.remote.FirestoreChannel$1.onMessage(com.google.firebase:firebase-firestore@@21.4.3:124)
at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:33)
at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:33)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:563)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(com.google.firebase:firebase-firestore@@21.4.3:229)
at java.lang.Thread.run(Thread.java:919)
Caused by: io.grpc.StatusException: PERMISSION_DENIED: Missing or insufficient permissions.
at io.grpc.Status.asException(Status.java:541)
at com.google.firebase.firestore.util.Util.exceptionFromStatus(com.google.firebase:firebase-firestore@@21.4.3:115)
... 27 more

最佳答案

计费方案和安全规则不相关。

您的规则拒绝任何未经用户登录的请求。这是使您的查询正常工作唯一需要满足的条件。这里没有足够的信息来了解用户未登录的原因(如果这是您所期望的),但根据您在此处显示的内容,这是“权限被拒绝”的唯一原因。您必须进行一些调试才能解决这个问题。

关于android - Firebase 身份验证有效,但 firestore 拒绝请求,因为权限缺失或不足,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63771241/

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