Java 连接到Google Firestore时出现未经验证的问题

Java 连接到Google Firestore时出现未经验证的问题,java,firebase,firebase-authentication,google-cloud-firestore,Java,Firebase,Firebase Authentication,Google Cloud Firestore,我正在使用Google Cloud Firestore测试版,并根据Google提供的文档编写了一个非常简单的代码。我在执行时遇到未经验证的错误。代码如下所示,与文档中提供的一些代码片段非常相似 String keyPath = "mykeystore.json"; FirestoreOptions firestoreOptions = FirestoreOptions.getDefaultInstance().toBuilder().setProjectId("test-project-111

我正在使用Google Cloud Firestore测试版,并根据Google提供的文档编写了一个非常简单的代码。我在执行时遇到未经验证的错误。代码如下所示,与文档中提供的一些代码片段非常相似

String keyPath = "mykeystore.json";
FirestoreOptions firestoreOptions = FirestoreOptions.getDefaultInstance().toBuilder().setProjectId("test-project-111").setCredentials(ServiceAccountCredentials.fromStream(new FileInputStream(keyPath))).build();
Firestore db = firestoreOptions.getService();
DocumentReference docRef = db.collection("users").document("alovelace");
// Add document data  with id "alovelace" using a hashmap
Map<String, Object> data = new HashMap<>();
data.put("first", "Ada");
data.put("last", "Lovelace");
data.put("born", 1815);
//asynchronously write data
ApiFuture<WriteResult> result = docRef.set(data);
try 
{
    result.get();
} catch (InterruptedException e) 
{
    e.printStackTrace();
} catch (ExecutionException e) 
{
    e.printStackTrace();
}

I am getting the error at the "result.get()" line of the code. The error is as below:
String keyPath=“mykeystore.json”;
FirestoreOptions FirestoreOptions=FirestoreOptions.getDefaultInstance().toBuilder().setProjectId(“test-project-111”).setCredentials(ServiceAccountCredentials.fromStream(新文件输入流(keyPath))).build();
Firestore db=firestoreOptions.getService();
DocumentReference docRef=db.collection(“用户”).document(“用户”);
//使用hashmap添加id为“alovelace”的文档数据
映射数据=新的HashMap();
数据。put(“第一”、“Ada”);
数据。put(“last”、“Lovelace”);
数据。put(“出生”,1815年);
//异步写入数据
ApiFuture result=docRef.set(数据);
尝试
{
result.get();
}捕捉(中断异常e)
{
e、 printStackTrace();
}捕获(执行例外)
{
e、 printStackTrace();
}
我在代码的“result.get()”行中得到错误。错误如下:
[信息]GCLOUD:java.util.concurrent.ExecutionException:com.google.api.gax.rpc.UnauthenticatedException:io.grpc.StatusRuntimeException:UNAUTHENTICATED

连接到Google Firestore时出现未经验证的问题

测试版

这是CloudFireStore的测试版。此产品可能以向后不兼容的方式更改,并且不受任何SLA或弃用策略的约束

。随着产品的成熟,功能可用性以及对产品集成和平台的支持将继续提高。有关Cloud Firestore中现有限制的更多信息,请参阅限制和配额文档


验证firestore Api密钥和Id

连接到Google Firestore时出现未经验证的问题

测试版

这是CloudFireStore的测试版。此产品可能以向后不兼容的方式更改,并且不受任何SLA或弃用策略的约束

。随着产品的成熟,功能可用性以及对产品集成和平台的支持将继续提高。有关Cloud Firestore中现有限制的更多信息,请参阅限制和配额文档


验证firestore Api密钥和Id

在此处共享完整堆栈跟踪:验证firestore Api密钥和Id在此处共享完整堆栈跟踪:验证firestore Api密钥和Id