Skip to content

GoogleAuth: Windows: Failing to retrieve the default project Id #18860

Open

Description

@asmith-wowcorp

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.stderr

returns None

Note that I can see the project name appear briefly in a popup window after that subprocess call.

What Works

  1. The gcloud CLI retrieves the project as expected
gcloud config get project
  1. Calling the Google Cloud SDK python gcloud.py with 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

Activity

  1. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    triage meI really want to be triaged.
    on Oct 27, 2026
  2. huong8373tt-beep commented on Oct 28, 2026

    @huong8373tt-beep

    I’m taking a focused look at the Windows gcloud.cmd invocation 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.

  3. huong8373tt-beep commented on Oct 28, 2026

    @huong8373tt-beep

    I tested the Windows invocation path before changing google-auth.

    Using an isolated CLOUDSDK_CONFIG with an official Cloud CLI install, I set a test project and then invoked gcloud.cmd config get project from Python with captured output. The configured project was returned on stdout as expected. I also repeated the call with CREATE_NO_WINDOW and with hidden STARTUPINFO; both captured the same output.

    The current gcloud.cmd runs its Python entry point synchronously rather than using start, so the local reproduction does not support a google-auth change 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.cmd path (where gcloud), CLOUDSDK_PYTHON / CLOUDSDK_PYTHON_ARGS values, 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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions