fix: removes `content-header` from AWS IMDS get request (#1934) · googleapis/google-auth-library-python@97bfea9 · GitHub
Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit 97bfea9

Browse files
authored
fix: removes content-header from AWS IMDS get request (#1934)
When performing a IMDS request, the code incorrectly adds a content-type header to the request: `content-type: application/json` to AWS metadata (IMDS) GET requests.` Some services at AWS (such as AWS SageMaker Jupyter notebook) have a stricter than normal metadata server (IMDS, both v1 and v2) when it comes to handling incoming http requests. This PR removes the default content-header and replaces it with `None`. NOTE: initializing headers to `None` (instead of an empty `dict`) when no session token is present matches the existing behavior in `_get_metadata_role_name` and allows the transport adapter to handle default headers cleanly. This PR updates existing unit tests (`tests/test_aws.py`) to match the new behavior. NOTE: closing PR #1489 due to inactivity as we make the push to migrate this library to the `google-cloud-python` monorepo For more information about the genesis of this, see the following issue: https://issuetracker.google.com/issues/328089077
1 parent 35670fc commit 97bfea9

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

google/auth/aws.py

Lines changed: 3 additions & 2 deletions

tests/test_aws.py

Lines changed: 2 additions & 8 deletions

0 commit comments

Comments
 (0)