Skip to content

Conversation

sai-sunder-s
Copy link
Contributor

For certain scenarios, custom headers are required to be sent to the backend along with usual headers like authorization, x-goog-user-project. Exposing a way for users to specify these custom headers.

@sai-sunder-s sai-sunder-s marked this pull request as ready for review September 16, 2025 17:37
@sai-sunder-s sai-sunder-s requested review from a team as code owners September 16, 2025 17:37
"""
import copy

PROTECTED_HEADERS = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to capture this in a more central way? I worry that we are missing some now or may miss some in the future if new ones get added

for example

_METADATA_HEADERS = {_METADATA_FLAVOR_HEADER: _METADATA_FLAVOR_VALUE}

creds_with_header.before_request(request, "http://example.com", "GET", headers)
assert headers["X-Custom-Header"] == "value1"
assert "authorization" in headers # Ensure base apply logic ran
assert creds_with_header is not credentials
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what you're trying to test here but as I understand python, this will never be true.

i.e. if you did:

credentials_a = CredentialsImpl()
credentials_b = CredentialsImpl()
assert credentials_a is not credentials_b # success 

assert c._use_non_blocking_refresh


def test_with_headers():
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this test is testing multiple scenarios. could you break it up so that we are testing ~1 thing per test?

https://engdoc.corp.google.com/eng/doc/tott/episodes/726.md?cl=head


self._use_non_blocking_refresh = False
self._refresh_worker = RefreshThreadManager()
self._custom_headers = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not used?

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.

2 participants