RayWangQvQ/BiliBiliToolPro · error · BiliIntegrationException

登录超时

Error message

登录超时

What it means

Thrown by LoginByQrCodeAsync when the QR code login polling loop finishes without ever receiving a confirmed cookie. The user either never scanned the QR code, didn't confirm on the phone, or the code expired before confirmation, so cookieInfo remains null and a BiliIntegrationException '登录超时' is raised.

Solutions

  1. Rerun the login command and scan + confirm the QR code promptly on the Bilibili app.
  2. If the console QR is unreadable, use the web QR code flow (GenerateQrCodeWebAsync) or copy the QR URL manually.
  3. Increase the polling timeout if you need more time to scan.
Defensive patterns

Strategy: try-catch

Try / catch

try
{
    var cookie = await loginDomainService.LoginByQrCodeAsync();
}
catch (BiliIntegrationException ex) when (ex.Message == "登录超时")
{
    logger.LogInformation("未在时限内扫码确认,请重新运行登录命令");
}

Prevention

When it happens

Trigger: The polling loop over passportApi.CheckQrCode times out (typically ~120-190s) because the QR code was never scanned, scan wasn't confirmed, or the code expired (QR codes expire quickly).

Common situations: Running headless/scheduled and not scanning in time; console not rendering the QR code legibly; Bilibili QR expired because the login attempt started long before scanning.

Related errors


AI-assisted analysis of RayWangQvQ/BiliBiliToolPro@c599b2c0da (2026-09-12). Data as JSON: /api/errors/77572469331b251a. Report an issue: GitHub.

Appendix: source

Thrown at src/Ray.BiliBiliTool.DomainService/LoginDomainService.cs:108

                logger.LogInformation("扫描成功!");
                IEnumerable<string> cookies = check
                    .Headers.SingleOrDefault(header => header.Key == "Set-Cookie")
                    .Value;

                var cookieStr = CookieInfo.ConvertSetCkHeadersToCkStr(cookies);

                cookieInfo = CookieStrFactory<BiliCookie>.CreateNew(cookieStr);
                cookieInfo.Check();

                break;
            }

            logger.LogInformation("{msg}", content.Data.Message + Environment.NewLine);
        }

        if (cookieInfo == null)
        {
            throw new BiliIntegrationException("登录超时");
        }

        return cookieInfo;
    }

    public async Task<BiliCookie> SetCookieAsync(
        BiliCookie biliCookie,
        CancellationToken cancellationToken
    )
    {
        try
        {
            var homePage = await homeApi.GetHomePageAsync(biliCookie.ToString());
            if (homePage.IsSuccessStatusCode)
            {
                logger.LogInformation("访问主站成功");
                IEnumerable<string> setCookieHeaders = homePage
                    .Headers.SingleOrDefault(header => header.Key == "Set-Cookie")

View on GitHub (pinned to c599b2c0da)