refactor: use Authorization header for API authentication#9
Merged
Conversation
…API key Migrate API key authentication from query parameters to Authorization header following security best practices and Geocodio API documentation recommendations. This reduces code duplication by centralizing auth header injection in the _request method. - Add Authorization header with Bearer token in _request method - Remove redundant api_key parameter initialization from all API methods - Make params parameter optional in _request method (defaults to empty dict) - Remove TODO comment about repeated API key handling
Update all test mocks to match the new authentication implementation using Authorization headers instead of query parameters. - Update httpx_mock fixtures to use match_headers with Bearer token - Remove api_key from query parameter expectations in all test files - Ensure all error mapping and geocoding tests pass with new auth format
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.
Summary
_requestmethodChanges
_requestmethod to automatically add Authorization header with Bearer tokenapi_keyparameter initialization from all API methods (geocode, reverse, list operations)paramsparameter optional in_requestmethod, defaulting to empty dict when not providedTest Plan
Unit Tests (✅ All Passing)
test_client.py- Client initialization and basic geocoding teststest_geocode.py- Forward geocoding with various parameterstest_reverse.py- Reverse geocoding with various parameterstest_errors.py- Error handling with proper authenticationTest Execution
Breaking Changes
None - The public API remains unchanged. This is an internal implementation improvement that maintains backward compatibility.