From d7136af8b83d0c8024fee5e6e8b33e65ca97d14a Mon Sep 17 00:00:00 2001 From: lalmstrom Date: Fri, 22 May 2026 22:02:08 +0200 Subject: [PATCH 1/3] Support Auth requests when Appcheck is enabled --- auth/src/desktop/rpcs/auth_request.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/auth/src/desktop/rpcs/auth_request.cc b/auth/src/desktop/rpcs/auth_request.cc index a4f4b9dd3b..f16f480f23 100644 --- a/auth/src/desktop/rpcs/auth_request.cc +++ b/auth/src/desktop/rpcs/auth_request.cc @@ -20,13 +20,19 @@ #include #include "app/src/app_common.h" +#include "app/src/function_registry.h" #include "app/src/heartbeat/heartbeat_controller_desktop.h" #include "app/src/include/firebase/app.h" +#include "app/src/include/firebase/future.h" #include "app/src/include/firebase/internal/mutex.h" #include "auth/src/desktop/auth_desktop.h" #include "auth/src/include/firebase/auth.h" #include "firebase/log.h" +namespace { +const int kAppCheckTokenTimeoutMs = 10000; +} // namespace + namespace firebase { namespace auth { @@ -50,6 +56,19 @@ AuthRequest::AuthRequest(::firebase::App& app, const char* schema, } } } + + // Add AppCheck attestation token if available. + // This is required when AppCheck enforcement is enabled on the project. + Future app_check_future; + bool succeeded = app.function_registry()->CallFunction( + ::firebase::internal::FnAppCheckGetTokenAsync, &app, nullptr, + &app_check_future); + if (succeeded && app_check_future.status() != kFutureStatusInvalid) { + const std::string* token = app_check_future.Await(kAppCheckTokenTimeoutMs); + if (token) { + add_header("X-Firebase-AppCheck", token->c_str()); + } + } } std::string AuthRequest::GetUrl() { From f263a9020ede89ece260b5f4f49a022de67c62fb Mon Sep 17 00:00:00 2001 From: lalmstrom Date: Fri, 22 May 2026 22:38:54 +0200 Subject: [PATCH 2/3] Release notes --- release_build_files/readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/release_build_files/readme.md b/release_build_files/readme.md index c63c527a5e..5f39f61888 100644 --- a/release_build_files/readme.md +++ b/release_build_files/readme.md @@ -617,6 +617,7 @@ code. - Changes - General (iOS, tvOS, Desktop): iOS, tvOS, and macOS SDKs are now built using Xcode 26.2. + - Auth (Windows): Fixes Auth requests when Appcheck is enabled. ### 13.7.0 - Changes From cb602fcbdc01e5ef23ccea2f8d40a4cf4378751b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Almstr=C3=B6m?= Date: Sat, 23 May 2026 08:57:07 +0200 Subject: [PATCH 3/3] Update to auth_request.cc after gemini-code-assist review Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- auth/src/desktop/rpcs/auth_request.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/auth/src/desktop/rpcs/auth_request.cc b/auth/src/desktop/rpcs/auth_request.cc index f16f480f23..6fcd07983b 100644 --- a/auth/src/desktop/rpcs/auth_request.cc +++ b/auth/src/desktop/rpcs/auth_request.cc @@ -59,14 +59,17 @@ AuthRequest::AuthRequest(::firebase::App& app, const char* schema, // Add AppCheck attestation token if available. // This is required when AppCheck enforcement is enabled on the project. - Future app_check_future; - bool succeeded = app.function_registry()->CallFunction( - ::firebase::internal::FnAppCheckGetTokenAsync, &app, nullptr, - &app_check_future); - if (succeeded && app_check_future.status() != kFutureStatusInvalid) { - const std::string* token = app_check_future.Await(kAppCheckTokenTimeoutMs); - if (token) { - add_header("X-Firebase-AppCheck", token->c_str()); + ::firebase::internal::FunctionRegistry* registry = app.function_registry(); + if (registry) { + Future app_check_future; + bool succeeded = registry->CallFunction( + ::firebase::internal::FnAppCheckGetTokenAsync, &app, nullptr, + &app_check_future); + if (succeeded && app_check_future.status() != kFutureStatusInvalid) { + const std::string* token = app_check_future.Await(kAppCheckTokenTimeoutMs); + if (token && app_check_future.error() == 0 && !token->empty()) { + add_header("X-Firebase-AppCheck", token->c_str()); + } } } }