1

我正在使用Google Cloud Firestore Beta,並根據Google提供的文檔編寫了一個非常簡單的代碼。我在執行它時遇到了未認證的錯誤。代碼如下,與文檔中提供的一些代碼片段非常相似。連接到Google Firestore時未經認證的問題

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

+0

這裏分享完整的堆棧跟蹤: –

+0

驗證您公司的FireStore API密鑰&ID https://cloud.google.com/firestore/docs/solutions/search – 2017-10-07 23:51:37

回答

0

UNAUTHENTICATED問題連接到谷歌公司的FireStore

貝塔

這是雲計算的一個測試版公司的FireStore。本產品可能以不兼容的方式進行更改,並且不受任何SLA或棄用政策的約束。

Cloud Firestore is currently in beta release。產品集成和平臺的功能可用性和支持將隨着產品的成熟而不斷提高。對於雲計算公司的FireStore上的現有限制的詳細信息,請參閱限制和配額文件

驗證您公司的FireStore API密鑰&標識 Cloud Firestore Security Rules