'Accessing data in Python from Firestore database without admin privelege

I need to acces Firestore database. I'm working on a projet and need to analys its data but I only have reading rights on it. Therefore I can't generate an SDK key.

I tried with the pyrebase lib but it won't work:

import pyrebase
firebaseConfig = {
"I put here the config with apiKIey, authDomain etc..."}

firebase = pyrebase.initialize_app(firebaseConfig)

#Get a reference to the database service
db = firebase.database()

#data to save
data = db.child("annonces").get()


Solution 1:[1]

I believe you are using the wrong python package. You can import firebase and firestore, as well as retrieve a collection as follows:

    from firebase_admin import credentials, firestore, initialize_app

    firebaseConfig = {...}
    cred = credentials.Certificate(firebaseConfig)
    firebase_app = initialize_app(cred)
    db = firestore.client()

    data = []
    announce_docs = db.collection("users").stream()

    for doc in announce_docs:
        announcement = doc.to_dict()
        data.append(user)

You can find more info in the Offical Docs

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1