New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FirebaseError: Missing or insufficient permissions. #8201
Comments
Hi @realexp3rt, thanks for the report. I tried replicating, but I wasn't able to reproduce the error. If I can replicate the issue, I can have a better look into it. Please share a minimal, but complete sample of a project that I can run locally. |
I don't know but it seems like the issue occurs whenever someone signs in. The already signed in user will have this issue for a couple of seconds then it will go away after a couple re-logins. Here is my /api/user.js which fetchs the user information from the database whenever the user refreshes the page:
It's linked with an AuthContext to be synced all over the app. And for /api/signin.js
Notice that i'm taking the approach of server-side with sign in and database reads. I don't want anything exposed to the client. |
Thanks for the additional code snippet, @realexp3rt. I just want to clarify my investigation regarding this issue since we have two error messages here: For the permission error, could you verify that the user is currently signed-in before performing the read/write in the database. There shouldn't be any issue if the user is signed-in before doing any activity on the database. For the grpc issue, I noticed that there are similar reported connectivity issue in version
Lastly, there are a lot of fixes on Firebase Firestore, would you mind trying to the update the SDK version that you're using and see if the issue persists? |
It looks like.. when a user signs in, every signed in user session changes to this new user thus rendering insufficient permissions since the uid won't match! how is this happening I don't understand! can you figure it out from these code snippets? |
Seems like an unsynchronized auth users. I did await auth.currentUser.email; in my user.js and saw the output. Whenever a new user signs in the whole app auth changes to that user and to be honest.. i'm not sure why |
Hi @realexp3rt, I used the given code snippet you've provided, unfortunately, I'm not encountering the error. I'm not totally clear how you are using the |
Well I fixed it. TL;DR since i'm using server-side auth and auth isn't synced in client-side whenever a user signs in it changes the whole app currentUser to the last signed in. And since i'm using a request.auth.uid == userId; it wouldn't give them permession. So I deleted that and everything worked well. Since i'm verifying the idToken in the back-end everything should be good. Sorry for the trouble. But the timeout issue still exists. I updated my SDK but how exactly can I set Thanks! |
Glad to know that syncing authentication between client and server fixed the issue. To enable
|
Thanks for your efforts. <3 |
Operating System
Linux
Browser Version
Firebase SDK Version
9.22.0
Firebase SDK Product:
Database, Firestore
Describe your project's tooling
Next.js app
Describe the problem
Lately i've been facing issues when I switched the project to another server. Sometimes when a user reads the database through this function:
I get these errors occasionally but not every time.
@firebase/firestore: Firestore (9.22.0): GrpcConnection RPC 'Listen' stream 0x367a9933 error. Code: 1 Message: 1 CANCELLED: Disconnecting idle stream. Timed out waiting for new targets.
[FirebaseError: Missing or insufficient permissions.] { code: 'permission-denied', customData: undefined, toString: [Function (anonymous)] }
Everything was working before i'm not sure what the issue is.
Here is my firebase init code:
And here are my security rules
Steps and code to reproduce issue
I'm not sure
The text was updated successfully, but these errors were encountered: