Skip to content

fix: avoid deprecated aiohttp basic auth API - #944

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

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>
@Pybsama
Pybsama marked this pull request as ready for review August 29, 2026 03:48
@Pybsama

Pybsama commented Aug 29, 2026

Copy link
Copy Markdown
Author

Revalidated this change against the current main (306691e7, eight commits after the PR base) before marking it ready for review. The public head remains unchanged.

  • The existing commit applies cleanly to current main; stable patch-id: d15a59ea7b33a32e27f4133e375d5b2580bd4f25.
  • Python 3.14.6 + the repository-pinned aiohttp 3.14.1: 17/17 focused tests and 639/639 non-cluster tests passed.
  • Python 3.9.6 + the declared minimum aiohttp 3.8.4: 17/17 focused tests passed.
  • Real local aiohttp probes passed with deprecations treated as errors, including same-origin credential retention, cross-origin credential stripping, retry behavior, and URL-credential conflict handling.
  • Both Flake8 commands, repository-wide Black (786 files), Autoflake, and git diff --check passed.
  • Current main still uses the deprecated BasicAuth / auth= path, and no equivalent open PR was found.

The legacy Test and Deploy and Lint PR runs attached to this PR both ended with startup_failure before creating any jobs. The same two workflows are currently failing at startup for main schedules and unrelated PRs as well, while the repository's newer CI workflow has successful runs; no test job from those legacy runs executed this patch.

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