Skip to content

Bug: QR login check_state never detects CONF/DONE status #1

Description

@jamese5095

Issue Description

The QR code login flow never completes - check_state() never returns CONF or DONE status even after user scans and confirms the QR code.

Environment

  • macOS
  • bilibili-api Python library
  • Python 3.12

Steps to Reproduce

  1. Run python bili_login.py
  2. Scan QR code with Bilibili app
  3. Confirm login on phone
  4. Script continues to print "已扫码,请在手机上确认..." indefinitely

Expected Behavior

  • After QR scan + confirmation, check_state() should return QrCodeLoginEvents.CONF then QrCodeLoginEvents.DONE
  • Credentials should be saved to bili_credential.json

Actual Behavior

  • Script loops forever showing "已扫码,请在手机上确认..."
  • check_state() keeps returning QrCodeLoginEvents.SCAN (1) instead of CONF (2) or DONE (3)
  • No credential file is ever created

Possible Root Cause

  • The bilibili-api library may have changed its enum values
  • Or network issue with B站 API
  • Or the check_state() is not properly detecting the confirmation

Workaround Attempted

  • Modified MCP server to check credential file first (didnt help as file is never created)
  • Used multiple QR code scans

Code Analysis

The login loop in bili_login.py:

while True:
    state = await qr.check_state()
    if state == QrCodeLoginEvents.SCAN:
        print("已扫码,请在手机上确认...")
    elif state == QrCodeLoginEvents.CONF:
        print("已确认...")
    # ...
    await asyncio.sleep(2)

The issue is that check_state() always returns SCAN even after confirmation.

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