AsifArmanRahman / firebase-rest-api

A simple python wrapper for Google's Firebase REST API's.

Home Page:https://firebase-rest-api.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

the rules file in firestore not working

furjac opened this issue · comments

What would you like to share?

so basically i was trying to store data but a error poped up like
Error during signup: [Errno 403 Client Error: Forbidden for url:
https://firestore.googleapis.com/v1/projects/fgsmmpanel/databases/(default)/doc
uments:commit?key=apikey {
"error": {
"code": 403,
"message": "Missing or insufficient permissions.",
"status": "PERMISSION_DENIED"
}
}

and this is the rule file config
Error during signup: [Errno 403 Client Error: Forbidden for url:
https://firestore.googleapis.com/v1/projects/fgsmmpanel/databases/(default)/doc
uments:commit?key=AIzaSyBUizgx29lr-l07YEjylOgQRDe5WSdnmyA] {
"error": {
"code": 403,
"message": "Missing or insufficient permissions.",
"status": "PERMISSION_DENIED"
}
}
and this is the code

user_doc = fsdb.collection('users-wallet').document(user_info_['users'][0]['email']).get()
wallet_balance = user_doc.get('wallet', 0)

Additional information

what am doing wrong or is it wrong with rules file cuz if i give
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
allow read, write;
}
}
it works fine

im so stressed

Please follow the instruction from firestore here.

As the issue is not a bug of the library, it'll be closed.

no i mean if i used : if request.auth != null this then why its not working then the data base not at all writeable
nor readable

image
ok this is the result maybe i have to use like this

but how to use can u give a simple example

@furjac

When you have the below rule for firestore

if request.auth != null

user = auth.sign_in_with_email_and_password(email, password)

data = {
   "name": "Iron Man"
}

db.collection('Marvels').document('Movies').set(data, token=user['idToken'])