【发布时间】:2019-04-23 15:03:21
【问题描述】:
我目前正在 C# 中探索 Firebase 的 Cloud Firestore,并遇到了在搜索 SO 后无法解决的错误。看来 C# 中 Firestore 的资源相当有限:
"Status(StatusCode=PermissionDenied, Detail=\"Missing or insufficient permissions.\")"
到目前为止我的代码:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "FirebaseCsharpTest.json");
string project = "MyProjectId";
FirestoreDb db = FirestoreDb.Create(project);
Console.WriteLine("Created Cloud Firestore client with project ID: {0}", project);
AddPerson(db).GetAwaiter().GetResult();
}
public static async Task AddPerson(FirestoreDb db)
{
CollectionReference collection = db.Collection("users");
DocumentReference document = await collection.AddAsync(new
{
Name = new
{ First = "Ada", Last = "Lovelace" },
Born = 1815
});
}
}
我在 Firebase 控制台上检查了 Firestore 安全规则是否设置为公开(截至目前,为了测试)。我还确保验证 json 文件是从 Google Developer Console 生成的正确文件,如 post 中所建议的那样。
我有什么遗漏吗?
【问题讨论】:
-
我也遇到了同样的问题,你找到解决办法了吗?
标签: c# firebase google-cloud-firestore