UiPath Documentation
orchestrator
2023.10
false
Orchestrator API 指南
重要 :
新发布内容的本地化可能需要 1-2 周的时间才能完成。

在 Swagger 中授权 API 调用

直接在 Orchestrator Swagger 界面中授权和执行 API 调用

访问 Swagger

要访问 Orchestrator API Swagger,请将 /swagger/index.html 附加到 Orchestrator URL。例如 https://{yourDomain}/swagger/index.html

您在 Swagger 中看到的 API 直接取决于您使用的 Orchestrator 实例。要轻松地直接在 Swagger 中发出请求,请在另一个选项卡中登录 Orchestrator。

获取访问令牌

要通过 Swagger 用户界面为 Orchestrator 服务授权 API 调用,请执行以下步骤:

  1. 在 Orchestrator API 页面 的右上角找到“授权”按钮。如果锁是打开的,则表示您未经授权。

    图 1. “授权”按钮 “授权”按钮

  2. 选择“授权”。此时将显示“可用授权”窗口。

    备注:

    我们目前支持一种名为 OAuth2 的授权方案。

    图 2. 可用授权

  3. All scopes are preselected such that you can experiment with all endpoints in the Orchestrator API.

Clear them if you want to restrict access to certain APIs. 4. Select Authorize. A new window is displayed confirming you have been authorized. 5. Once done, select Close or X to close the Available authorizations window. The Authorize button shows an closed lock meaning you are authorized.

正在发送请求

获得授权后,您可以对 Orchestrator API 资源发出请求,如下所示:

  1. 展开要用于执行操作的 Orchestrator API 资源。 已关闭的锁定表示您已获得授权。

    图 3. 未授权的 API 资源

  2. 在展开的方法窗口中,选择“试用”。

  3. 根据需要指定参数值。

  4. 选择“执行”。请求已执行。“持有者授权”标头会自动用于您的请求。

    图 4. “持有者授权”标头

生成新的访问令牌

当访问令牌过期时,您会收到 401: You are not authenticated! 响应。 您的请求仍存在不记名授权标头,但访问令牌已过期。 发生这种情况时,您需要使过期的令牌失效并生成新的访问令牌:

  1. 在 Orchestrator API 页面 的右上角找到“授权”按钮。锁应该已关闭。

    图 5.“授权”按钮 “授权”按钮

  2. 选择“授权”,然后在显示的“可用授权”页面上选择“注销”,以撤销过期令牌。

    图 6. 可用授权

  3. 单击“关闭”或 "X" 以关闭“可用授权”窗口,然后按照“获取访问令牌”部分中的说明获取访问令牌。

撤销访问权限

使用完 Swagger 用户界面后,您应该使已使用的访问令牌失效:

  1. 在 Orchestrator API 页面 的右上角找到“授权”按钮。锁应该已关闭,表示您已获得授权。
  2. Select Authorize and on the displayed Available authorizations page, Select Logout.
  3. 单击“关闭”或 "X",关闭“可用授权”窗口。“授权”按钮显示打开的锁,表示您未获得授权。

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新