AsifArmanRahman / firebase-rest-api

A simple python wrapper for Google's Firebase REST API's.
https://firebase-rest-api.readthedocs.io
MIT License
59 stars 14 forks source link

the rules file in firestore not working #32

Closed furjac closed 7 months ago

furjac commented 7 months ago

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(userinfo['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

AsifArmanRahman commented 7 months ago

Please follow the instruction from firestore here.

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

furjac commented 7 months ago

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

furjac commented 7 months ago

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

furjac commented 7 months ago

but how to use can u give a simple example

furjac commented 7 months ago

@AsifArmanRahman https://stackoverflow.com/questions/78101477/firestore-missing-or-insufficient-permission-firebase-rest-api-python plz visit this

AsifArmanRahman commented 7 months ago

@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'])