@@ -2564,19 +2564,6 @@ def _discover_api_accounts_by_id_scan(self, *, proxies: Any = None) -> list[dict
25642564 return rows
25652565
25662566 def _load_accounts_from_api (self , * , proxies : Any = None ) -> list [dict [str , Any ]]:
2567- pre_status , pre_payload , pre_text = self ._api_request (
2568- "POST" ,
2569- "/api/open/messages" ,
2570- json_body = {"id" : 1 },
2571- proxies = proxies ,
2572- timeout = max (5 , int (round (self ._api_scan_req_timeout ))),
2573- )
2574- if self ._is_api_token_invalid (pre_status , pre_payload , pre_text ):
2575- raise MailServiceError (
2576- "Graph 接口模式鉴权失败:开放接口 token 无效。"
2577- "请填写上游 MAIL_API_TOKEN(不是后台登录密码)。"
2578- )
2579-
25802567 paths = [
25812568 "/api/open/accounts" ,
25822569 "/api/open/accounts/list" ,
@@ -2585,6 +2572,7 @@ def _load_accounts_from_api(self, *, proxies: Any = None) -> list[dict[str, Any]
25852572 "/api/open/mailbox/list" ,
25862573 ]
25872574 last_err = ""
2575+ login_required_hit = False
25882576 for path in paths :
25892577 status , payload , text = self ._api_request ("GET" , path , proxies = proxies , timeout = 30 )
25902578 if status == 404 :
@@ -2598,6 +2586,7 @@ def _load_accounts_from_api(self, *, proxies: Any = None) -> list[dict[str, Any]
25982586 )
25992587 last_err = f"{ path } HTTP { status } : { err_detail or text } "
26002588 if self ._is_api_login_required (status , payload , text ):
2589+ login_required_hit = True
26012590 break
26022591 continue
26032592
@@ -2620,6 +2609,13 @@ def _load_accounts_from_api(self, *, proxies: Any = None) -> list[dict[str, Any]
26202609 return rows
26212610 last_err = f"{ path } 返回成功但未包含可用账号列表"
26222611
2612+ if login_required_hit :
2613+ raise MailServiceError (
2614+ "Graph 接口模式拉取账号列表失败:上游返回未登录或会话过期。"
2615+ "请确认已调用开放接口 /api/open/accounts,"
2616+ "并使用 MAIL_API_TOKEN(或 INGEST_TOKEN 回退)进行鉴权。"
2617+ )
2618+
26232619 scanned_rows = self ._discover_api_accounts_by_id_scan (proxies = proxies )
26242620 if scanned_rows :
26252621 self ._api_accounts_discovered_by_scan = True
0 commit comments