Skip to content

fix: avoid deprecated aiohttp basic auth API - #944

Draft
Pybsama wants to merge 1 commit into
twilio:mainfrom
Pybsama:codex/avoid-deprecated-aiohttp-basicauth
Draft

fix: avoid deprecated aiohttp basic auth API#944
Pybsama wants to merge 1 commit into
twilio:mainfrom
Pybsama:codex/avoid-deprecated-aiohttp-basicauth

Conversation

@Pybsama

@Pybsama Pybsama commented Jul 31, 2026

Copy link
Copy Markdown

Fixes

Fixes #931

Replace the deprecated aiohttp BasicAuth / auth= request path with an Authorization header in AsyncTwilioHttpClient.

The implementation feature-detects encode_basic_auth so the declared aiohttp>=3.8.4 range remains supported, explicitly preserves the historical Latin-1 wire encoding, rejects conflicting Authorization headers case-insensitively, and does not mutate caller-provided headers. The network call no longer passes the auth keyword, which also avoids the second aiohttp 3.14 deprecation and remains compatible with its planned removal in aiohttp 4.

Validation

  • Python 3.9.6 + aiohttp 3.8.4: 17 focused tests passed
  • Python 3.14.6 + aiohttp 3.14.3: 17 focused tests passed
  • Real local aiohttp request with aiohttp deprecations treated as errors: passed
  • Full non-cluster suite: 639 tests passed
  • make analysis: passed
  • Changed-file Black, Autoflake, and git diff --check: passed

make test reaches the repository-wide Black check and stops on the pre-existing formatting of tests/unit/rest/test_client.py. That file is unchanged from main; the complete pytest suite and both Flake8 commands were run separately as listed above.

Checklist

  • I acknowledge that all my contributions will be made under the project license
  • I have made a material change to the repo
  • I have read the Contribution Guidelines and this PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove the fix is effective
  • No user-facing documentation is needed because the public API and authentication behavior are unchanged
  • I have documented the compatibility helper added by this change

Encode asynchronous Basic Auth credentials as an Authorization header without using aiohttp’s deprecated BasicAuth request path. Preserve the SDK’s aiohttp 3.8.4 compatibility, Latin-1 wire encoding, validation, and header-conflict behavior.

Signed-off-by: sama Pyb <peiyibopybsama@gmail.com>
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.

[BUG] BasicAuth is deprecated and will be removed in aiohttp 4.0

1 participant