Google Cloud Firestore Betaを使用しており、Googleが提供するドキュメントに基づいて非常に簡単なコードを書いています。私はそれを実行中にUNAUTHENTICATEDエラーが発生しています。コードは以下のとおりであり、ドキュメントに記載されている一部のコードと非常によく似ています。Google Firestoreに接続中にUNAUTHENTICATED問題が発生しました
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:
[INFO]のgcloud:java.util.concurrent.ExecutionException:com.google.api.gax.rpc.UnauthenticatedException:io.grpc.StatusRuntimeException:UNAUTHENTICATED
: –
あなたのfirestore APIキー&IDを検証しますhttps://cloud.google.com/firestore/docs/solutions/search –