From fe498e5e296cee22083bd332e25e7e1c1281b077 Mon Sep 17 00:00:00 2001 From: austinbenoit Date: Thu, 3 Dec 2026 20:11:17 +0000 Subject: [PATCH] Auth (Desktop): send heartbeats on SecureTokenRequest Pass deliver_heartbeat = true in SecureTokenRequest so returning desktop users refreshing persisted sessions via securetoken.googleapis.com/v1/token attach the stored heartbeat header (x-firebase-client) and X-Firebase-GMPID, matching the other Auth desktop requests and Firebase iOS Auth. Update AuthRequestHeartbeatTest to verify SecureTokenRequest includes the heartbeat and GMP App ID headers. --- auth/src/desktop/rpcs/secure_token_request.cc | 2 +- auth/tests/desktop/rpcs/auth_request_heartbeat_test.cc | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/auth/src/desktop/rpcs/secure_token_request.cc b/auth/src/desktop/rpcs/secure_token_request.cc index 34274d0dfd..08596b0990 100644 --- a/auth/src/desktop/rpcs/secure_token_request.cc +++ b/auth/src/desktop/rpcs/secure_token_request.cc @@ -27,7 +27,7 @@ namespace auth { SecureTokenRequest::SecureTokenRequest(::firebase::App& app, const char* api_key, const char* refresh_token) - : AuthRequest(app, request_resource_data, false) { + : AuthRequest(app, request_resource_data, true) { FIREBASE_ASSERT_RETURN_VOID(api_key); const char api_host[] = "securetoken.googleapis.com/v1/token?key="; diff --git a/auth/tests/desktop/rpcs/auth_request_heartbeat_test.cc b/auth/tests/desktop/rpcs/auth_request_heartbeat_test.cc index d327397b62..78ebc66dcd 100644 --- a/auth/tests/desktop/rpcs/auth_request_heartbeat_test.cc +++ b/auth/tests/desktop/rpcs/auth_request_heartbeat_test.cc @@ -128,13 +128,13 @@ TEST_F(AuthRequestHeartbeatTest, TestResetPasswordRequestHasHeartbeat) { #endif // FIREBASE_PLATFORM_DESKTOP #if FIREBASE_PLATFORM_DESKTOP -TEST_F(AuthRequestHeartbeatTest, TestSecureTokenRequestDoesNotHaveHeartbeat) { +TEST_F(AuthRequestHeartbeatTest, TestSecureTokenRequestHasHeartbeat) { SecureTokenRequest request(*app_, "APIKEY", "email"); - // SecureTokenRequest should not have heartbeat payload since it is sent - // to a backend that does not support the payload. - EXPECT_EQ("", request.options().header[app_common::kApiClientHeader]); - EXPECT_EQ("", request.options().header[app_common::kXFirebaseGmpIdHeader]); + // The request headers should include both heartbeat payload and GMP App ID. + EXPECT_NE("", request.options().header[app_common::kApiClientHeader]); + EXPECT_EQ("com.google.firebase.testing", + request.options().header[app_common::kXFirebaseGmpIdHeader]); } #endif // FIREBASE_PLATFORM_DESKTOP