UNAUTHENTICATED:凭据需要具有 PRIVACY_AND_INTEGRITY 安全级别的通道。观察到的安全级别:NONE
UNAUTHENTICATED: Credentials require channel with PRIVACY_AND_INTEGRITY security level. Observed security level: NONE
使用带有 java 的 firebase admin sdk 将我的后端服务器连接到 firestore。
这是我进行 firebase 设置的初始化方法
public void initialize() throws IOException {
FileInputStream serviceAccount = new FileInputStream(GOOGLE_APPLICATION_CREDENTIALS);
GoogleCredentials credentials = GoogleCredentials.fromStream(serviceAccount);
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(credentials)
.build();
FirebaseApp.initializeApp(options);
}
我的项目在 运行 Cloud firestore 时工作正常,但是当我尝试通过添加环境变量 FIRESTORE_EMULATOR_HOST运行 使用 firestore 本地模拟器时=21=] 我遇到了以下问题
Caused by: com.google.api.gax.rpc.UnauthenticatedException: io.grpc.StatusRuntimeException: UNAUTHENTICATED: Credentials require channel with PRIVACY_AND_INTEGRITY security level. Observed security level: NONE
at com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:73)
at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:72)
at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:60)
at com.google.api.gax.grpc.ExceptionResponseObserver.onErrorImpl(ExceptionResponseObserver.java:82)
at com.google.api.gax.rpc.StateCheckingResponseObserver.onError(StateCheckingResponseObserver.java:86)
at com.google.api.gax.grpc.GrpcDirectStreamController$ResponseObserverAdapter.onClose(GrpcDirectStreamController.java:149)
at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:426)
at io.grpc.internal.ClientCallImpl.access0(ClientCallImpl.java:66)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:689)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access0(ClientCallImpl.java:577)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImplStreamClosed.runInternal(ClientCallImpl.java:751)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImplStreamClosed.runInContext(ClientCallImpl.java:740)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
我也遇到了这个问题...看起来这里修复了一个错误https://github.com/firebase/firebase-admin-java/issues/452
但是...如果您只导入 com.google.firebase:firebase-admin:7.1.0
,它似乎使用 google-cloud-firestore:1.35.0
,其中没有修复!
您需要指定这两个依赖项才能使其与 build.gradle
中的模拟器一起正常工作
implementation "com.google.firebase:firebase-admin:7.1.0"
implementation "com.google.cloud:google-cloud-firestore:2.1.0"
使用带有 java 的 firebase admin sdk 将我的后端服务器连接到 firestore。
这是我进行 firebase 设置的初始化方法
public void initialize() throws IOException {
FileInputStream serviceAccount = new FileInputStream(GOOGLE_APPLICATION_CREDENTIALS);
GoogleCredentials credentials = GoogleCredentials.fromStream(serviceAccount);
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(credentials)
.build();
FirebaseApp.initializeApp(options);
}
我的项目在 运行 Cloud firestore 时工作正常,但是当我尝试通过添加环境变量 FIRESTORE_EMULATOR_HOST运行 使用 firestore 本地模拟器时=21=] 我遇到了以下问题
Caused by: com.google.api.gax.rpc.UnauthenticatedException: io.grpc.StatusRuntimeException: UNAUTHENTICATED: Credentials require channel with PRIVACY_AND_INTEGRITY security level. Observed security level: NONE
at com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:73)
at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:72)
at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:60)
at com.google.api.gax.grpc.ExceptionResponseObserver.onErrorImpl(ExceptionResponseObserver.java:82)
at com.google.api.gax.rpc.StateCheckingResponseObserver.onError(StateCheckingResponseObserver.java:86)
at com.google.api.gax.grpc.GrpcDirectStreamController$ResponseObserverAdapter.onClose(GrpcDirectStreamController.java:149)
at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:426)
at io.grpc.internal.ClientCallImpl.access0(ClientCallImpl.java:66)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:689)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access0(ClientCallImpl.java:577)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImplStreamClosed.runInternal(ClientCallImpl.java:751)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImplStreamClosed.runInContext(ClientCallImpl.java:740)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
我也遇到了这个问题...看起来这里修复了一个错误https://github.com/firebase/firebase-admin-java/issues/452
但是...如果您只导入 com.google.firebase:firebase-admin:7.1.0
,它似乎使用 google-cloud-firestore:1.35.0
,其中没有修复!
您需要指定这两个依赖项才能使其与 build.gradle
implementation "com.google.firebase:firebase-admin:7.1.0"
implementation "com.google.cloud:google-cloud-firestore:2.1.0"