Skip to content

Auth (Desktop): Route SecureTokenRequest and SignUpRequest to Auth Emulator - #1937

Open
AustinBenoit wants to merge 2 commits into
mainfrom
emulator-fix
Open

AustinBenoit wants to merge 2 commits into
mainfrom
emulator-fix

Conversation

@AustinBenoit

@AustinBenoit AustinBenoit commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Provide details of the change, and generalize the change in the PR title above.

SecureTokenRequest (token refresh / GetToken) and SignUpRequest (linking an email/password credential to an anonymous account) hardcoded https:// production endpoints instead of calling AuthRequest::GetUrl(), bypassing the Auth Emulator.


Testing

Describe how you've tested these changes. Link any manually triggered Integration tests or CPP binary SDK Packaging Github Action workflows, if applicable.

Test manually with local test app. Added unit test to verify


Type of Change

Place an x the applicable box:

  • Bug fix. Add the issue # below if applicable.
  • New feature. A non-breaking change which adds functionality.
  • Other, such as a build process or documentation change.

Notes

  • Bug fixes and feature changes require an update to the Release Notes section of release_build_files/readme.md.
  • Read the contribution guidelines CONTRIBUTING.md.
  • Changes to the public API require an internal API review. If you'd like to help us make Firebase APIs better, please propose your change in a feature request so that we can discuss it together.

Fixes: #1934

…ulator

SecureTokenRequest (token refresh / GetToken) and SignUpRequest (linking
an email/password credential to an anonymous account) hardcoded https://
production endpoints instead of calling AuthRequest::GetUrl(), bypassing
the Auth Emulator.

Parameterize AuthRequest::GetUrl(const char* server_url = kServerURL),
use GetUrl(api_host) in SecureTokenRequest and SignUpRequest, and add
unit tests verifying both production and emulator URLs across all desktop
Auth RPC request classes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request fixes an issue where SecureTokenRequest and SignUpRequest were always sent to production endpoints instead of the Auth Emulator. This is resolved by modifying AuthRequest::GetUrl to accept a dynamic server_url parameter, and updating the requests and tests accordingly. Regarding the feedback, a potential issue was identified in AuthRequest::GetUrl where the server_url parameter is not checked for nullptr before being appended to a std::string, which could lead to undefined behavior or crashes.

Comment on lines +76 to 77
std::string AuthRequest::GetUrl(const char* server_url) {
Auth* auth_ptr = Auth::GetAuth(&app);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The server_url parameter is a raw pointer (const char*) and is not checked for nullptr before being appended to std::string on lines 84 and 90. Appending a null pointer to a std::string results in undefined behavior (typically a crash). Consider adding a defensive check at the beginning of the function to handle a null server_url gracefully.

std::string AuthRequest::GetUrl(const char* server_url) {\n  if (server_url == nullptr) {\n    return "";\n  }\n  Auth* auth_ptr = Auth::GetAuth(&app);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Desktop Auth token refresh ignores UseEmulator() and targets production

2 participants