'Use python-firestore AsyncClient, with firebase

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=???)


Solution 1:[1]

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),
)

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 Ivan Reshetnikov