Reputation: 774
Currently I have firebase account setup. I wish to add item to firestore of this project, via python asyncio.
As I understand it, the package: python-firestore
, does support async via AsyncClient
.
The python package firebase_admin
, currently doos not support async. So I am wondering if it is possible to use it without firebase_admin
.
firebase_admin:
import firebase_admin
from firebase_admin import credentials
cred = credentials.Certificate("path/to/serviceAccountKey.json")
firebase_admin.initialize_app(cred)
python-firestore:
from google.cloud.firestore import AsyncClient
client = AsyncClient(credentials=???)
Upvotes: 3
Views: 3081
Reputation: 774
After digging in the source code, I found the answer myself.
from google.cloud.firestore import AsyncClient
from google.oauth2 import service_account
with open("path/to/serviceAccountKey.json") as json_file:
json_data = json.load(json_file)
firestore_client = AsyncClient(
project=json_data['project_id'],
credentials=service_account.Credentials.from_service_account_info(json_data),
)
Upvotes: 6