From 764f26de9601031c06ae4e1978df8c2b6038f50c Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Mon, 16 Sep 2024 11:25:54 -0400 Subject: [PATCH] Enable AppCheck --- .../Sources/Internal/GrpcClient.swift | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/FirebaseDataConnect/Sources/Internal/GrpcClient.swift b/FirebaseDataConnect/Sources/Internal/GrpcClient.swift index 863c2cb4425..1056edb20a3 100644 --- a/FirebaseDataConnect/Sources/Internal/GrpcClient.swift +++ b/FirebaseDataConnect/Sources/Internal/GrpcClient.swift @@ -41,8 +41,6 @@ actor GrpcClient: CustomStringConvertible { private let auth: Auth - private let appCheckEnabled = false - private let appCheck: AppCheck? private enum RequestHeaders { @@ -196,22 +194,20 @@ actor GrpcClient: CustomStringConvertible { } // Add AppCheck token if available - if appCheckEnabled { - do { - if let token = try await appCheck?.token(forcingRefresh: false) { - headers.add(name: RequestHeaders.appCheckHeader, value: "\(token)") - FirebaseLogger.dataConnect - .debug("App Check token added: \(token)") - } else { - FirebaseLogger.dataConnect - .debug("App Check token unavailable. Not adding App Check header.") - } - } catch { + do { + if let token = try await appCheck?.token(forcingRefresh: false) { + headers.add(name: RequestHeaders.appCheckHeader, value: token.token) + FirebaseLogger.dataConnect + .debug("App Check token added: \(token.token)") + } else { FirebaseLogger.dataConnect - .debug( - "Cannot get App Check token successfully due to: \(error). Not adding App Check header." - ) + .debug("App Check token unavailable. Not adding App Check header.") } + } catch { + FirebaseLogger.dataConnect + .debug( + "Cannot get App Check token successfully due to: \(error). Not adding App Check header." + ) } let options = CallOptions(customMetadata: headers)