我无法使用 Python 在 Google Firebase (Cloud Firestore) 数据库中获取、更新或创建文档。
我拥有的:
B) 凭证 JSON 文件另存为test.json(path/to/serviceKey.json在文档中经常调用),如下所示(已编辑):
{
"type": "service_account",
"project_id": "test-6f02d",
"private_key_id": "fffca ... 5b7",
"private_key": "-----BEGIN PRIVATE KEY-----\n ... 1IHE=\n-----END PRIVATE KEY-----\n",
"client_email": "test-admin@test-6f02d.iam.gserviceaccount.com",
"client_id": "112 ... 060",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/ ... .gserviceaccount.com"
}
Run Code Online (Sandbox Code Playgroud)
此用户具有角色Owner。
C)firebase_admin 安装(使用virtualenv,pip),我可以这样做:
{
"type": "service_account",
"project_id": "test-6f02d",
"private_key_id": "fffca ... 5b7",
"private_key": "-----BEGIN PRIVATE KEY-----\n ... 1IHE=\n-----END PRIVATE KEY-----\n",
"client_email": "test-admin@test-6f02d.iam.gserviceaccount.com",
"client_id": "112 ... …Run Code Online (Sandbox Code Playgroud)