c# - Firestore C#:权限缺失或不足
问题描述
我目前正在 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 生成的正确文件,如本文中所建议的那样。
有什么我想念的吗?
解决方案
请检查您添加的项目 ID。ProjectID 应该是您的 json 文件中指定的那个。
推荐阅读
- c - 作为参数传递时结构混乱
- reactjs - 将局部图块渲染为
在反应传单中 - r - 丢弃一个预测类时 randomForest 包的奇怪行为
- powerbi - Power BI Analysis Services 数据源用户名和密码
- javascript - 使用 Angular 跳过焦点或激活禁用的按钮
- reactjs - 为 React Apollo 订阅客户端配置 onSubscriptionData
- html - 设置为“无”的 HTML 图像显示在设置为阻止时不会显示
- php - Foreach 数组只接收最后一个键
- php - PHP - 如何在 whileloop 中赋值并在其他页面上访问它们
- android - Android中可自定义的浮动按钮