Android 从GAE开发服务器使用Firestore时出现未经验证的异常
我正在制作一个Android应用程序,它使用云端点框架作为后端API。我正在使用AppEngine开发服务器测试后端。在一个后端函数中,我尝试调用以从Firestore数据库获取文档,但出现以下错误: com.google.api.server.spi.SystemService invokeServiceMethod 严重:调用后端方法时发生异常 java.util.concurrent.ExecutionException:io.grpc.StatusRuntimeException:UNAUTHENTICATED 位于com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:500) 位于com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:479) 在com.google.api.core.AbstractApiFuture.get(AbstractApiFuture.java:57)上 我相信我的服务帐户设置正确。我将环境变量GOOGL\u APPLICATION\u CREDENTIALS设置为服务帐户密钥的路径。我还将遵循有关实例化和调用Firestore的指南:Android 从GAE开发服务器使用Firestore时出现未经验证的异常,android,google-app-engine,google-cloud-endpoints,google-cloud-firestore,Android,Google App Engine,Google Cloud Endpoints,Google Cloud Firestore,我正在制作一个Android应用程序,它使用云端点框架作为后端API。我正在使用AppEngine开发服务器测试后端。在一个后端函数中,我尝试调用以从Firestore数据库获取文档,但出现以下错误: com.google.api.server.spi.SystemService invokeServiceMethod 严重:调用后端方法时发生异常 java.util.concurrent.ExecutionException:io.grpc.StatusRuntimeException:UNA
import com.google.cloud.firestore.Firestore;
import com.google.cloud.firestore.FirestoreOptions;
FirestoreOptions firestoreOptions =
FirestoreOptions.getDefaultInstance().toBuilder()
.setProjectId(projectId)
.build();
Firestore db = firestoreOptions.getService();
db.collection(collectionId).get().get();
我在这里遗漏了什么东西可以从GAE给Firestore打电话吗?在与这个问题斗争了一段时间后,我偶然发现了一个临时解决方法。看起来db确实还没有经过身份验证,在获取服务以获取请求元数据后添加调用似乎会触发身份验证
Firestore db = firestoreOptions.getService();
try {
// somehow without this it does not work on the local server
db.getOptions().getCredentials().getRequestMetadata();
} catch (IOException e) {
e.printStackTrace();
}
... // db access works on local server!
我想我的团队和我有同样的问题,我们在Firebase Firestore的项目中使用了服务器和Android应用程序。你在找到解决方案方面有什么进展吗?