MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / _submit_auth_start

Method _submit_auth_start

src/core/register.py:664–787  ·  view source on GitHub ↗

提交授权入口表单 Returns: SignupFormResult: 提交结果,包含账号状态判断

(
        self,
        did: str,
        sen_token: Optional[str],
        *,
        screen_hint: str,
        referer: str,
        log_label: str,
        record_existing_account: bool = True,
    )

Source from the content-addressed store, hash-verified

662 return None
663
664 def _submit_auth_start(
665 self,
666 did: str,
667 sen_token: Optional[str],
668 *,
669 screen_hint: str,
670 referer: str,
671 log_label: str,
672 record_existing_account: bool = True,
673 ) -> SignupFormResult:
674 """
675 提交授权入口表单
676
677 Returns:
678 SignupFormResult: 提交结果,包含账号状态判断
679 """
680 max_attempts = 3
681 current_did = str(did or "").strip()
682 current_sen_token = str(sen_token or "").strip() if sen_token else None
683 for attempt in range(1, max_attempts + 1):
684 try:
685 request_body = json.dumps({
686 "username": {
687 "value": self.email,
688 "kind": "email",
689 },
690 "screen_hint": screen_hint,
691 })
692
693 headers = self._build_json_headers(
694 referer=referer,
695 include_device_id=True,
696 did=current_did,
697 )
698 if current_sen_token:
699 headers["openai-sentinel-token"] = current_sen_token
700
701 response = self.session.post(
702 OPENAI_API_ENDPOINTS["signup"],
703 headers=headers,
704 data=request_body,
705 )
706
707 self._log(f"{log_label}状态: {response.status_code}")
708
709 if response.status_code == 429 and attempt < max_attempts:
710 wait_seconds = min(18, 5 * attempt)
711 self._log(
712 f"{log_label}命中限流 429(第 {attempt}/{max_attempts} 次),{wait_seconds}s 后自动重试...",
713 "warning",
714 )
715 time.sleep(wait_seconds)
716 continue
717
718 # 部分网络/会话边界情况下会返回 409,做自愈重试而非直接失败。
719 if response.status_code == 409 and attempt < max_attempts:
720 wait_seconds = min(10, 2 * attempt)
721 self._log(

Calls 8

_build_json_headersMethod · 0.95
_logMethod · 0.95
_check_sentinelMethod · 0.95
SignupFormResultClass · 0.85
sleepMethod · 0.80
postMethod · 0.45
getMethod · 0.45
jsonMethod · 0.45