From 984293ebaa7c5327b514d445b1f8b8504dac451a Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Wed, 18 Sep 2024 11:10:52 -0400 Subject: [PATCH] Enable AppCheck Support --- Sources/Internal/GrpcClient.swift | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/Sources/Internal/GrpcClient.swift b/Sources/Internal/GrpcClient.swift index 0ee67b4..c8829c4 100644 --- a/Sources/Internal/GrpcClient.swift +++ b/Sources/Internal/GrpcClient.swift @@ -40,8 +40,6 @@ actor GrpcClient: CustomStringConvertible { private let auth: Auth - private let appCheckEnabled = false - private let appCheck: AppCheck? private enum RequestHeaders { @@ -195,22 +193,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)