'How to debug firebase_admin on python
I am having trouble debugging firebase_admin.
I know that my auth token is working, as the login bit works, but the second I try to access a document from the firestore, things get "silent".
Doing this:
from firebase_admin import firestore
def getUserByUID(uid):
print(uid)
db = firestore.client()
print('before')
user = db.collection(u'users').document(uid).get().to_dict()
print(user)
print('after')
if not user:
raise Exception(f"The user requested with the uid: {uid} does not exist in Users collection")
if not user.get("uid", None):
user["uid"] = uid
return user
Results in:
8XXXXXXXXXXXXX1
before
I can see the document in firestore. It is there and it has a lot of values.
But when doing this:
from firebase_admin import firestore
def getUserByUID(uid):
print(uid)
db = firestore.client()
print('before')
user = db.collection(u'users').document(uid)
print('after')
if not user:
raise Exception(f"The user requested with the uid: {uid} does not exist in Users collection")
if not user.get("uid", None):
user["uid"] = uid
return user
I can see this:
8XXXXXXXXXXXXXXX1
before
<google.cloud.firestore_v1.document.DocumentReference object at 0x1CCCCC0>
after
It is just failing silently and I don't see any option to debug this.
Any hint is really welcome.
Solution 1:[1]
Turned out to be a broken firebase-admin installation via PIP. Not sure why there is no debugging function, but now it is working again.
Try reinstalling firebase-admin if you are facing the same issue.
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 | David |
