RayWangQvQ/BiliBiliToolPro · error · BiliBusinessException
登录失败,请检查Cookie
Error message
登录失败,请检查Cookie
What it means
AccountDomainService.LoginByCookie calls the nav (nav/get) API with the cookie and throws BiliBusinessException when the API returns a non-zero code or IsLogin is false — meaning the cookie did not authenticate a valid session.
Solutions
- Re-export a fresh cookie from a logged-in browser and update your config.
- Confirm SESSDATA and bili_jct are copied completely and unencoded from devtools.
- Log back into bilibili if the session was invalidated (logout, password change, risk control).
- Run BiliCookie.Check() first to catch structural problems before hitting the API.
Example fix
// before (stale cookie in config) "BiliCookie": "DedeUserID=12345; SESSDATA=expired...; bili_jct=old" // after (freshly exported cookie) "BiliCookie": "DedeUserID=12345; SESSDATA=fresh%2Cvalue; bili_jct=newtoken"
Defensive patterns
Strategy: try-catch
Validate before calling
// validate structure first, then verify login non-destructively
try { cookie.Check(); } catch (BiliValidationException) { /* fix config before calling LoginByCookie */ } Try / catch
try { var user = await accountDomainService.LoginByCookie(cookie); }
catch (BiliBusinessException ex)
{
logger.LogError("登录失败,Cookie 已失效或无效: {Msg}", ex.Message);
// prompt for cookie re-export and abort run
} Prevention
- Re-export the cookie periodically; SESSDATA expires.
- Never reuse cookies after logout or password change.
- Call Check() before LoginByCookie to separate config errors from auth errors.
When it happens
Trigger: Calling LoginByCookie with an expired, revoked, or malformed SESSDATA/bili_jct; the nav API responding with code != 0 or Data.IsLogin == false.
Common situations: Cookie expired (Bili rotates SESSDATA periodically); user logged out or changed password after copying the cookie; cookie copied from a different/mismatched account fields; environment where cookies were partially sanitized.
Related errors
- re.Message
- Unsupported algorithm
- Cookie字符串格式异常,内部无等号
- Cookie字符串异常,无[ ]项
- [ ]= 不能转换为long型,请确认配置的是正确的Cookie值
AI-assisted analysis of RayWangQvQ/BiliBiliToolPro@c599b2c0da (2026-09-12).
Data as JSON: /api/errors/d5af5d3151357e43.
Report an issue: GitHub.
Appendix: source
Thrown at src/Ray.BiliBiliTool.DomainService/AccountDomainService.cs:42
IOptionsMonitor<UnfollowBatchedTaskOptions> unfollowBatchedTaskOptions,
IOptionsMonitor<DailyTaskOptions> dailyTaskOptions
) : IAccountDomainService
{
private readonly UnfollowBatchedTaskOptions _unfollowBatchedTaskOptions =
unfollowBatchedTaskOptions.CurrentValue;
private readonly DailyTaskOptions _dailyTaskOptions = dailyTaskOptions.CurrentValue;
/// <summary>
/// 登录
/// </summary>
/// <returns></returns>
public async Task<UserInfo> LoginByCookie(BiliCookie cookie)
{
BiliApiResponse<UserInfo> apiResponse = await navApi.GetNavAsync(cookie.ToString());
if (apiResponse.Code != 0 || !apiResponse.Data!.IsLogin)
{
throw new BiliBusinessException("登录失败,请检查Cookie");
}
UserInfo useInfo = apiResponse.Data;
logger.LogInformation("【用户名】{0}", useInfo.GetFuzzyUname());
logger.LogInformation("【会员类型】{0}", useInfo.VipType.Description());
logger.LogInformation("【会员状态】{0}", useInfo.VipStatus.Description());
logger.LogInformation("【硬币余额】{0}", useInfo.Money ?? 0);
if (useInfo.Level_info?.Current_level < 6)
{
logger.LogInformation(
"【距升级Lv{0}】预计{1}天",
useInfo.Level_info.Current_level + 1,
CalculateUpgradeTime(useInfo)
);
}
elseView on GitHub (pinned to c599b2c0da)