fxmacrodata: send the API key as a header, not a query parameter - #51
Open
roberttidball wants to merge 1 commit into
Open
fxmacrodata: send the API key as a header, not a query parameter#51roberttidball wants to merge 1 commit into
roberttidball wants to merge 1 commit into
Conversation
FXMacroData accepts the key three ways and documents X-API-Key as the preferred transport for server-side clients. The provider was appending it to the query string instead, so the key was written verbatim into every proxy, CDN and server access log along the request path, and into any local HTTP debug output. Switch to a per-request header so the behaviour still tracks self.api_key rather than freezing it into the session at construction, and leave headers unset entirely when no key is configured. Covered by three tests: the existing request test now asserts the header and the absence of an api_key parameter, plus one that no parameter value carries the key and one that no auth header is sent without a key. The keyless test clears the environment, since otherwise an ambient FXMACRODATA_API_KEY would be picked up and the assertion would pass for the wrong reason. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The FXMacroData provider appends the API key to the query string:
FXMacroData accepts the key three ways and its OpenAPI spec documents
X-API-Keyas the preferred transport for server-side clients, precisely because a key in the query string is written verbatim into every proxy, CDN and server access log along the request path, and into any local HTTP debug output. The other keyed providers in this repo are unaffected; each has its own_request_json.This switches to a per-request header, so the behaviour still tracks
self.api_keyrather than freezing it into the session at construction, and no auth header is sent at all when no key is configured.Tests: the existing request test now asserts the header and the absence of an
api_keyparameter, plus two new ones - that no parameter value carries the key, and that no auth header is sent without a key. The keyless test clears the environment, since otherwise an ambientFXMACRODATA_API_KEYwould be picked up and the assertion would pass for the wrong reason.Checks:
pytest tests/test_fxmacrodata_provider.py23 passed,ruff check,ruff format --checkandty checkall clean.Disclosure: I work on FXMacroData. Thanks for building the provider - this is only about how the key is transported, nothing about the data.
🤖 Generated with Claude Code