Repository navigation
GoogleAuth: Windows: Failing to retrieve the default project Id #18860
Copy link
Copy link
Open
Labels
triage meI really want to be triaged.I really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Determine this is the right repository
- I determined this is the correct repository in which to report this bug.
Summary of the issue
Context
After creating a new venv, google.auth no longer retrieves my default project id
Expected Behavior:
import google.auth
creds, project = google.auth.default()
Returns the project
Actual Behavior:
The project is returned as None along with a warning
API client name and version
google.auth v2.62.0
Reproduction steps: code
import google.auth
creds, project = google.auth.default()Reproduction steps: supporting files
No response
Reproduction steps: actual results
project: None
Reproduction steps: expected results
project: <redacted>
OS & version + platform
Windows 11 Enterprise 25H2
Python environment
Python 3.13.17
Python dependencies
google.auth v 2.62.0
Google Cloud SDK 590.0.1
Additional context
The function:
google.auth._cloud_sdk.get_project_id()returns None
probably because the subprocess call:
import subprocess
import pathlib
gcloud_cmd = pathlib.Path(r'~\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin\gcloud.cmd').expanduser()
result = subprocess.run([str(gcloud_cmd), 'config', 'get', 'project'], capture_output=True, text=True)
result.stdout, result.stderrreturns None
Note that I can see the project name appear briefly in a popup window after that subprocess call.
What Works
- The gcloud CLI retrieves the project as expected
gcloud config get project- Calling the Google Cloud SDK python
gcloud.pywith a subprocess call:
def get_default_project() -> Optional[str]:
# this is a hack around issue https://github.com/googleapis/google-cloud-python/issues/18860
import sys
import pathlib
import subprocess
# first find the gcloud SDK code
result = subprocess.run(["where", "gcloud"], capture_output=True, text=True, check=False)
if len(result.stdout) == 0:
return
gcloud_path = pathlib.Path(result.stdout.splitlines()[0]).parent.parent
# now find the gcloud.py file in the SDK
gcloud_py = gcloud_path.joinpath("lib\\gcloud.py")
result = subprocess.run([sys.executable, gcloud_py, "config", "get", "project"], capture_output=True, text=True, check=False)
return result.stdout.strip()I guess the gcloud cli spawns another command window and the result isn't piped back
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
triage meI really want to be triaged.I really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Activity
huong8373tt-beep commentedon Oct 28, 2026
I’m taking a focused look at the Windows
gcloud.cmdinvocation path and will prepare a minimal fix with regression coverage if the current implementation reproduces the reported behavior.Disclosure: Slai Agent Runtime is assisting with the investigation, implementation, and testing. The account owner authorized the submitted changes and is responsible for the submission.
huong8373tt-beep commentedon Oct 28, 2026
I tested the Windows invocation path before changing
google-auth.Using an isolated
CLOUDSDK_CONFIGwith an official Cloud CLI install, I set a test project and then invokedgcloud.cmd config get projectfrom Python with captured output. The configured project was returned on stdout as expected. I also repeated the call withCREATE_NO_WINDOWand with hiddenSTARTUPINFO; both captured the same output.The current
gcloud.cmdruns its Python entry point synchronously rather than usingstart, so the local reproduction does not support agoogle-authchange that only adds a no-window flag: that flag can hide a console window, but would not restore stdout if an external launcher had detached it.I have not opened a PR because I could not reproduce the reported loss of project output with this path. If the issue remains reproducible, the most useful follow-up evidence would be the resolved
gcloud.cmdpath (where gcloud),CLOUDSDK_PYTHON/CLOUDSDK_PYTHON_ARGSvalues, and the exact captured return code/stdout/stderr from the affected environment.Disclosure: Slai Agent Runtime assisted with the investigation and test execution. The account owner authorized this contribution and is responsible for the submission.