oauth
feishu.agent.oauth
¶
build_authorize_url_builder
¶
Python
build_authorize_url_builder(provider: UserTokenProvider, signer: OAuthStateSigner, redirect_uri: str) -> AuthorizeUrlBuilder
preflight_authorization
async
¶
request_authorization
async
¶
Python
request_authorization(agent: Any, event: Event | ScheduledTurn, session_id: str, history: list[Message], call: ToolCall, result: ToolResult, progress: _ProgressCard | None = None, *, approved: PendingApproval | None = None) -> bool
为缺少用户授权的工具创建挂起授权并发送授权卡片;返回是否已挂起本轮。
挂起记录先于卡片送达落库;OAuth callback 成功后调用 resume_authorization 恢复原工具调用。
源代码位于: feishu/agent/oauth.py
| Python | |
|---|---|
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
cancel_pending_authorization
async
¶
persist_authorization_card_message_id
async
¶
Python
persist_authorization_card_message_id(agent: Any, authorization: PendingAuthorization, message_id: str) -> None
build_authorize_url
¶
send_auth_card
async
¶
Python
send_auth_card(agent: Any, event: Event, authorize_url: str, progress: _ProgressCard | None = None) -> bool
向当前会话发送一张授权卡片;缺少构造器、客户端或 chat 时返回 False。
源代码位于: feishu/agent/oauth.py
try_send_auth_card
async
¶
Python
try_send_auth_card(agent: Any, event: Event, authorize_url: str, progress: _ProgressCard | None = None) -> bool
发送授权卡片的不抛错封装:发送失败只记日志并返回 False。
源代码位于: feishu/agent/oauth.py
resume_authorization
async
¶
Python
resume_authorization(agent: Any, authorization_id: str, *, user: Mapping[str, Any] | None = None, propagate_errors: bool = False) -> str
Resume under the session lock; durable consumers propagate failures and freeze uncertain work.
notify_authorization_resume_problem
async
¶
Python
notify_authorization_resume_problem(agent: Any, authorization: PendingAuthorization, text: str) -> None
remove_authorization_card
async
¶
Python
remove_authorization_card(agent: Any, authorization: PendingAuthorization, *, card: dict[str, Any] | None = None) -> None
event_from_pending_authorization
¶
Python
event_from_pending_authorization(authorization: PendingAuthorization) -> Event | ScheduledTurn
oauth_callback_handler
¶
Python
oauth_callback_handler(provider: UserTokenProvider, signer: OAuthStateSigner, redirect_uri: str, *, on_authorized: AuthorizationResumeCallback | None = None, durable_receiver: Any | None = None, track_task: Callable[[Task[Any]], None] | None = None, success_message: str = '授权成功,正在回到飞书继续处理。', success_title: str = '授权完成', invalid_state_message: str = '授权校验失败:state 无效或已过期,请重新发起授权。', missing_code_message: str = '授权失败:回调缺少 code。', exchange_error_message: str = '授权失败:换取用户凭证时出错,请稍后再试。', user_mismatch_message: str = '授权失败:完成授权的用户与发起授权的用户不一致。') -> Callable[[Any], Any]
创建用于用户态工具授权回调的 Starlette 兼容处理函数。