Skip to content

Invalid Authentication when trying to add Blink integration in Home Assistant #1217

Description

@silverStSt

Describe the bug
The authentication process works correctly step by step; it asks for the 2FA SMS code, which arrives on my phone correctly, but then it fails to verify the code. It seems that the session cookies are lost between authentication and 2FA verification.

To Reproduce
Steps to reproduce the behavior:

  1. Install Blink complement
  2. Login Blink account
  3. Use sms code to 2fa

Expected behavior
A clear and concise description of what you expected to happen.

Home Assistant version (if applicable):
HA 2026.4.1 Core

blinkpy version (not needed if filling out Home Assistant version):
0.25.2

Log Output/Additional Information
It seems that session cookies are being lost when sending the 2FA code. I'm using Blink in the EU and my Blink account isn't linked to my Amazon account. I've tried deleting the integration and reinstalling it, restarting in between. This has been happening since at least October 2025, or even earlier. I've tried updating to different versions of Home Assistant. I use both the computer and the mobile app.

I've included messages in the blinkpy code, in auth.py, to analyze the authentication request and response, and this is the result.

2026-04-12 10:56:58.896 DEBUG (MainThread) [blinkpy.auth] Attempting OAuth v2 login flow
2026-04-12 10:57:00.258 INFO (MainThread) [blinkpy.auth] Two-factor authentication required.
2026-04-12 10:57:10.220 WARNING (MainThread) [blinkpy.api] ==== BLINK REQUEST ====
2026-04-12 10:57:10.221 WARNING (MainThread) [blinkpy.api] URL: 'https://api.oauth.blink.com/oauth/v2/2fa/verify'
2026-04-12 10:57:10.222 WARNING (MainThread) [blinkpy.api] HEADERS: {'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Mobile/15E148 Safari/604.1', 'Accept': '*/*', 'Content-Type': 'application/x-www-form-urlencoded', 'Origin': 'https://api.oauth.blink.com', 'Referer': 'https://api.oauth.blink.com/oauth/v2/signin'}
2026-04-12 10:57:10.222 WARNING (MainThread) [blinkpy.api] DATA (raw): {'2fa_code': '******', 'csrf-token': 'Kyyu+ksJS5XilceAZPXOg*************************************************MpPNw1+Dy0U5wFahpWEBrw==', 'remember_me': 'false'}
2026-04-12 10:57:10.223 WARNING (MainThread) [blinkpy.api] DATA (encoded): '2fa_code=******&csrf-token=Kyyu%2BksJS5XilceAZPXOg**********************************MpPNw1%2BDy0U5wFahpWEBrw%3D%3D&remember_me=false'
2026-04-12 10:57:10.374 WARNING (MainThread) [blinkpy.api] ==== BLINK RESPONSE ====
2026-04-12 10:57:10.375 WARNING (MainThread) [blinkpy.api] STATUS: 400
2026-04-12 10:57:10.376 WARNING (MainThread) [blinkpy.api] BODY: '{"error":"bad_request","error_cause":"empty_cookies","error_description":"Empty Cookies."}'
2026-04-12 10:57:10.376 ERROR (MainThread) [blinkpy.auth] 2FA verification failed
2026-04-12 10:57:10.377 ERROR (MainThread) [blinkpy.blinkpy] OAuth v2 2FA completion failed.
2026-04-12 10:57:10.396 DEBUG (MainThread) [blinkpy.auth] Attempting OAuth v2 login flow
2026-04-12 10:57:11.550 INFO (MainThread) [blinkpy.auth] Two-factor authentication required.
2026-04-12 10:57:11.555 WARNING (MainThread) [homeassistant.config_entries] Config entry 'blink' for blink integration could not authenticate: Required Blink re-authentication

Modify code por log:

async def oauth_verify_2fa(auth, csrf_token, twofa_code):
"""
Step 3b: Verify 2FA code.

Args:
auth: Auth instance
csrf_token: CSRF token
twofa_code: 2FA code from user

Returns:
bool: True if verification successful

"""
headers = {
"User-Agent": OAUTH_USER_AGENT,
"Accept": "/",
"Content-Type": "application/x-www-form-urlencoded",
"Origin": "https://api.oauth.blink.com",
"Referer": OAUTH_SIGNIN_URL,
}

data = {
"2fa_code": twofa_code,
"csrf-token": csrf_token,
"remember_me": "false",
}

_LOGGER.warning("==== BLINK REQUEST ====")
_LOGGER.warning("URL: %r", OAUTH_2FA_VERIFY_URL)
_LOGGER.warning("HEADERS: %r", headers)
_LOGGER.warning("DATA (raw): %r", data)
_LOGGER.warning("DATA (encoded): %r", urlencode(data))

response = await auth.session.post(OAUTH_2FA_VERIFY_URL, headers=headers, data=data)
text = await response.text()
_LOGGER.warning("==== BLINK RESPONSE ====")
_LOGGER.warning("STATUS: %r", response.status)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions