Enhance 2FA handling in OAuth flow#1228
Open
FxNion wants to merge 1 commit into
Open
Conversation
Handle alternate 2FA response status and restore cookies for verification.
16 tasks
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.
Handle alternate 2FA response status and restore cookies for verification.
Description:
Related issue : fixes #1217
Checklist:
toxrun successfully PR cannot be meged unless tests passPR description — fronzbot/blinkpy
Title:
fix: handle HTTP 202 response in oauth_signin and restore cookies for 2FA verificationSummary
Two fixes to the OAuth 2FA flow, identified and confirmed by tracing the full OAuth sequence in a live Home Assistant environment (June 2026).
Changes
1.
blinkpy/api.py—oauth_signin: handle HTTP 202 as 2FA requiredBlink's OAuth endpoint now returns HTTP 202 (in addition to, or instead of, 412) to signal that 2FA is required and a PIN has been sent. The function previously only handled 412 and returned
Nonefor any other status, causing the login flow to silently fail.This fix treats 202 and 412 identically, and captures the current cookie jar for reuse in the verification step.
2.
blinkpy/api.py—oauth_verify_2fa: restore cookies before verification POSTIn some
aiohttpconfigurations (notably when using HA's shared session), cookies accumulated duringoauth_signinare not preserved across requests. This fix explicitly restores the captured cookie jar before the verification POST, and passes them as request cookies as well.Observed behaviour before fix
Observed behaviour after fix
Testing
Tested on:
Related