Skip to content
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

Uncaught (in promise) FirebaseError: Missing or insufficient permissions. #369

Closed
ThigoPSI opened this issue May 16, 2019 · 46 comments
Closed

Comments

@ThigoPSI
Copy link

Hi, can anyone help me fix this error, I'm having a lot of trouble with firebase
Capturar

@Fleker
Copy link
Contributor

Fleker commented May 16, 2019

When you look at your Firestore rules, they should match:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read;
      allow write: if false;
    }
  }
}

If you do not allow read, you may see this issue in the client.

@ThigoPSI
Copy link
Author

this I have the same, I have been more than 1 week and I can not connect to firebase
Cadpturar

@Fleker
Copy link
Contributor

Fleker commented May 16, 2019

That seems to be a separate issue, unrelated to Firebase permissions, and may be related to an error on the server-side implementation that is causing the server to fail early so that it is not adding the CORS header to the response.

@ThigoPSI
Copy link
Author

and you think you can help me solve this ??

@Fleker
Copy link
Contributor

Fleker commented May 16, 2019

Are you noticing any errors in the server?

@ThigoPSI
Copy link
Author

which I do not see, it runs all right, but when I try to add a device of those mistakes I showed up, but be as it is there prints for you to see
server

@Fleker
Copy link
Contributor

Fleker commented May 16, 2019

What is 'smart-home-nodejs/frontend/functions'? This project is designed to use App Engine, not cloud functions.

@Fleker
Copy link
Contributor

Fleker commented May 16, 2019

Looking at the left-hand of the screen, the issue may be not including the smart-home-key.json while also running the service through ngrok (#366).

@guilhermelirio
Copy link

this I have the same, I have been more than 1 week and I can not connect to firebase
Cadpturar

Same error here! =/

@ghost
Copy link

ghost commented May 16, 2019

1+ #370 where is the solution?

@Fleker
Copy link
Contributor

Fleker commented May 16, 2019

It seems like there is an issue in your server-side App Engine implementation that is causing the implementation to crash.

@ghost
Copy link

ghost commented May 16, 2019

and this problem is on our side? or is it something that is wrong in the example?

@Fleker
Copy link
Contributor

Fleker commented May 16, 2019

Without seeing what logs are being sent in your server, it is hard to identify why it is crashing.

@ghost
Copy link

ghost commented May 16, 2019

Where can I go to get this log?

@Fleker
Copy link
Contributor

Fleker commented May 16, 2019

If it's hosted on App Engine, you can go to http://console.cloud.google.com/logs/viewer

@ThigoPSI
Copy link
Author

I use Firebase and the sample servers. How can I solve the problem? and where can I get the log?

@Fleker
Copy link
Contributor

Fleker commented May 17, 2019

If you go to the link above you should be able to view server logs.

@ThigoPSI
Copy link
Author

is there, do you think you can help me?

log.zip

@Fleker
Copy link
Contributor

Fleker commented May 17, 2019

None of the included logs contain an error

@ThigoPSI
Copy link
Author

So why on my smart home node server js (NGROk) do not seem like devices that I create on the smart frontend server at home?

@Fleker
Copy link
Contributor

Fleker commented May 17, 2019

You're using ngrok for the server?

@ThigoPSI
Copy link
Author

yes it is my local server.

and I want to simulate (add) devices on it

@Fleker
Copy link
Contributor

Fleker commented May 17, 2019

Okay. In that case, the problem is happening because the API calls are being made to a URL that does not exist. You'll need to follow a few steps as described in #366 to update your database connections, and update the API endpoint to your ngrok URL.

@ThigoPSI
Copy link
Author

is always giving error

2019-05-17T14_49_45_815Z-debug.zip

@Fleker
Copy link
Contributor

Fleker commented May 17, 2019

It seems the error is related to the command tsc && copy src/*.json dist/, which does not seem to be running as expected in your environment.

@Fleker Fleker closed this as completed May 17, 2019
@radianceltd
Copy link

radianceltd commented Apr 7, 2020

This my error

Error: 7 PERMISSION_DENIED: Missing or insufficient permissions.
    at Object.callErrorFromStatus (/srv/node_modules/firebase-admin/node_modules/@grpc/grpc-js/build/src/call.js:30:26)
    at Http2CallStream.call.on (/srv/node_modules/firebase-admin/node_modules/@grpc/grpc-js/build/src/client.js:96:33)
    at emitOne (events.js:121:20)
    at Http2CallStream.emit (events.js:211:7)
    at process.nextTick (/srv/node_modules/firebase-admin/node_modules/@grpc/grpc-js/build/src/call-stream.js:100:22)
    at _combinedTickCallback (internal/process/next_tick.js:132:7)
    at process._tickDomainCallback (internal/process/next_tick.js:219:9)

@radianceltd
Copy link

Can you help me out

@spieker
Copy link

spieker commented Jun 8, 2020

I don't know if this is the issue here, but when creating a new database in firebase, the default permissions are set to "allow everything for 1 week after creation". This looks something like this:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.time < timestamp.date(2020, 7, 1);
    }
  }
}

You can extend the permitted time by modifying timestamp.date(2020, 7, 1), or create propper permission rules.

@alirehman726
Copy link

Annotation 2020-08-08 153741

@Taaseen71
Copy link

Taaseen71 commented Aug 19, 2020

I had the same error, And after reading everything in the comments section, all i did was change it from

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.time < timestamp.date(2020, 7, 1);
    }
  }
}

to this

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write;
    }
  }
}

so basically allow read and write indefinitely, and my database showed up

@Noly17
Copy link

Noly17 commented Aug 29, 2020

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {

match /{document=**} {

//this code underneath is the thing. go change the date, i change mine 2020 to 2021
allow read, write: if request.time < timestamp.date(2021, 8, 29);
}
}
}

@astroana
Copy link

astroana commented Sep 1, 2020

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}

This is only applicable for development and not advisable for production. I have the same issue when changing rules with auth even though I detached the listener upon logout.

edit: I got mine working turns out the error was because of the useEffect in my context provider. This rule below works for me

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{uid} {
allow read, write: if request.auth.uid == uid
}
}
}

@Rian1010
Copy link

@Taaseen71 Hi! :) Where should it be added please? So, which file please?

@Oshanwick
Copy link

@alirehman726 its works thanks man

@kadebedis
Copy link

If this should be opened in a different issue, please let me know. I get the same error that people above are getting, but my application is able to read & write the data to the database. I just want to get the error to go away.

Has anyone else seen this issue?

image

@yoonghan
Copy link

yoonghan commented Nov 7, 2020

@Rian1010 login to https://console.firebase.google.com/, access Cloud Firestore.
From the tabs appeared - Data/Rules/Indexes/Usage. Select "Rules", and change to "allow read, write;". Save it.
Though i believe this will be a security issue in production, but for now it solves my problem.

Thanks @alirehman726 it worked.

@femzykel
Copy link

femzykel commented Dec 1, 2020

I had the same error, But all i did was changing the rule that works with the date and it worked perfectly. The current request.time was "<" the timestamp.date which invalidates the rule once the date/time elapse the date of the default rule.

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.time < timestamp.date(2020, 9, 10);
}
}
}
Updated to this

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.time > timestamp.date(2020, 9, 10);
}
}
}
so basically i reversed the lesser-than sign to greater-than sign giving access to my database to function as it should,
or you can just manually keep changing the date to extend permission without switching the the lesser-than sign to greater-than sign.

@emregurbulak
Copy link

Hi,
I got a same issue . The problem was about firebase test project time to expired .
Because the test project has a 30 days access permission.
I was create a new project on firebase and I took the configuration(firebaseConfig) and replaced it with the old firebaseConfig in my project code.

@crevulus
Copy link

Hi all, I've changed my rules to be more liberal but I still have the same error when I try to get() a collection. My rules are as follows:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /users/{userId} {
      allow read;
      allow write: if request.auth.uid == userId;
      allow update: if request.auth.uid == userId;
    }
  }
}

Previously, read followed the same structure as the rules for write and update. But I still get Uncaught (in promise) FirebaseError: Missing or insufficient permissions. even though I'm allowing all reads.

@imadelcass
Copy link

I don't know if this is the issue here, but when creating a new database in firebase, the default permissions are set to "allow everything for 1 week after creation". This looks something like this:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.time < timestamp.date(2020, 7, 1);
    }
  }
}

You can extend the permitted time by modifying timestamp.date(2020, 7, 1), or create propper permission rules.

Thanks a lot

@crevulus
Copy link

@imadelcass be careful using those rules. They're very insecure and it's not recommended.

@Thokya
Copy link

Thokya commented Jul 7, 2021

When you look at your Firestore rules, they should match:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read;
      allow write: if false;
    }
  }
}

If you do not allow read, you may see this issue in the client.

this worked for me thanks for the suggestion

@vishnusiju
Copy link

In firebase -> Cloud Firestore ->Rules,


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


Change To,

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}

@Adyaapatil09
Copy link

rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow read, write: if request.time < timestamp.date(2022, 12, 1); } } }
you might use these rules to just remember to change the dates when they expire!

@2003-r
Copy link

2003-r commented May 19, 2023

I have the same error with firebase store and I don't know how to fix it
whenever I am trying to upload files I need to upload the file in firebase storage and fields to firebase store , it store file to the storage but fail to store in firebase store
can anyone help me ?

@elvandiano
Copy link

In firebase -> Cloud Firestore ->Rules,

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

Change To,
rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow read, write; } } }

its work to me.. thanks guys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests