Firestore: Transactions giving permission denied

霸气de小男生 提交于 2019-12-05 21:07:54

I was running into this same issue, but I managed to fix it. Set up a service account and point your Firestore instance to that. You can create a service account key here. Here's a sample code block showing how to use the service account. SERVICE_ACCOUNT_PATH is a string that contains the path to the service account and PROJECT_ID is a string containing your project id.

private static void authenticate() throws Exception {
     FirestoreOptions firestoreOptions = FirestoreOptions.newBuilder()
          .setCredentials(ServiceAccountCredentials.fromStream(new FileInputStream(SERVICE_ACCOUNT_PATH)))
          .setProjectId(PROJECT_ID).build();

     database = firestoreOptions.getService();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!