Repository navigation
fix: send an Apinator User-Agent so Cloudflare doesn't block requests - #5
Merged
Merged
Conversation
Cloudflare in front of ws-{cluster}.apinator.io rejects urllib's default
"Python-urllib/x.y" User-Agent with error 1010 (403), before the request
reaches the API. Every call the SDK made against production failed with
AuthenticationError: API request failed: Forbidden.
Requests now carry "apinator-server-python/{version} (Python x.y.z)".
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.
Why
Every request this SDK makes to production is blocked. Cloudflare in front of
ws-{cluster}.apinator.iorejects urllib's defaultPython-urllib/3.xUser-Agent with error 1010 (HTTP 403) before the request reaches the API. Users would seeAuthenticationError: API request failed: Forbiddenand blame their keys.Same request, only the User-Agent differs:
Python-urllib/3.12error code: 1010(Cloudflare)apinator-server-python/1.0.0 (Python 3.12)invalid app_id(our API)Go-http-client/1.1,node,undici,GuzzleHttp/7,PHP, emptyNobody hit this yet because
apinator-serverwas never on PyPI.What changes
_requestsendsUser-Agent: apinator-server-python/{__version__} (Python x.y.z).test_trigger_single_channelasserts the header.Verification
ws-eu.apinator.iowith made-up credentials, the call now gets our API'sinvalid app_idinstead of Cloudflare's 1010.This should merge before the first PyPI release (#4, then the 1.1.0 release PR) so the first published version works.