Skip to content

Commit

Permalink
turn off App check before backend verification
Browse files Browse the repository at this point in the history
  • Loading branch information
cherylEnkidu committed Aug 19, 2024
1 parent 5183bad commit ebf7f1e
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions FirebaseDataConnect/Sources/Internal/GrpcClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ actor GrpcClient: CustomStringConvertible {

private let auth: Auth

private let appCheckEnabled = false

private let appCheck: AppCheck?

private enum RequestHeaders {
Expand Down Expand Up @@ -194,20 +196,22 @@ actor GrpcClient: CustomStringConvertible {
}

// Add AppCheck token if available
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 {
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 {
FirebaseLogger.dataConnect
.debug("App Check token unavailable. Not adding App Check header.")
.debug(
"Cannot get App Check token successfully due to: \(error). 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

0 comments on commit ebf7f1e

Please sign in to comment.