Skip to content

Drop mwoauth dependency, use oauthlib directly#998

Merged
LeMyst merged 3 commits into
masterfrom
issue-318
Jul 4, 2026
Merged

Drop mwoauth dependency, use oauthlib directly#998
LeMyst merged 3 commits into
masterfrom
issue-318

Conversation

@LeMyst

@LeMyst LeMyst commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Reimplements the 3-legged OAuth1 handshake (Special:OAuth/initiateauthenticatetoken) directly with requests_oauthlib.OAuth1 + requests, mirroring what mwoauth did under the hood, so the mwoauth dependency can be dropped.
  • Removes mwoauth from pyproject.toml / poetry.lock.
  • Fixes a latent bug in OAuth1.continue_oauth(): mediawiki_api_url, instantiation_time, and the session User-Agent header were never initialized after completing the handshake, which would raise AttributeError on the very first get_edit_token() call. continue_oauth() now delegates to _Login.__init__() like the owner-only flow already does.

Test plan

  • pytest test/test_wbi_login.py — added coverage for the full 3-legged OAuth1 flow (test_three_legged_flow, test_three_legged_flow_wrong_request_token) plus existing owner-only/CSRF-error tests
  • pytest test/ — full suite passes (193 passed)
  • mypy wikibaseintegrator/wbi_login.py — no issues
  • isort --check-only on changed files

Fixes #318

🤖 Generated with Claude Code

LeMyst and others added 3 commits July 4, 2026 10:11
Uses the target instance's own wbcheckconstraints API action (from the
WikibaseQualityConstraints extension) instead of a hardcoded, Wikidata-specific
rule set, so it works against any Wikibase instance with the extension installed.

Closes #154

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The 3-legged OAuth1 handshake (Special:OAuth/initiate, authenticate,
token) is reimplemented with requests_oauthlib.OAuth1 and requests,
mirroring what mwoauth did internally, removing the extra dependency.
Also fixes continue_oauth(), which previously crashed with an
AttributeError because mediawiki_api_url/instantiation_time were never
initialized after completing the handshake.

Fixes #318

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@LeMyst LeMyst merged commit 883a0dc into master Jul 4, 2026
15 checks passed
@LeMyst LeMyst deleted the issue-318 branch July 4, 2026 11:05
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.

Drop mwoauth dependency

1 participant