Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions FirebaseDataConnect/Sources/Internal/GrpcClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ actor GrpcClient: CustomStringConvertible {

private let auth: Auth

private let appCheckEnabled = false

private let appCheck: AppCheck?

private enum RequestHeaders {
Expand Down Expand Up @@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should appCheck be accessed via interop like the other products?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out. I will merge this public version into the new repo for now and explore interop way.

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)
Expand Down
Loading