<span id="查询插件账号授权状态"></span>

# Get plugin account authorization status

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

Read a plugin account's authorization state, connection version, and authorization generation.

```text
GET https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/plugin-connections/{connection_id}/authorization
```

<span id="调用前准备"></span>

## Before you call this API

Prepare the target workspace ID and a personal access token with resource access and permission for this action. Use actual resource identifiers for path `workspace_id` and `connection_id`, and put the workspace ID in `X-Workspace-ID`. See [common objects and inputs](objects.md#input-identifiers) for environment variable sources.

<span id="路径参数"></span>

## Path parameters

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Request example

```bash
curl -X GET "https://api.moi.matrixorigin.cn/v5/workspaces/$WORKSPACE_ID/plugin-connections/$CONNECTION_ID/authorization" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

:::::
:::::{tab-item} Parameters

An active connection does not mean the account is authorized. Without an authorization record, the response is not_connected with generation/revision 0. Not every authorization method returns attempt_id. Retain a nonempty attempt ID obtained from the authorization action.

This action accepts no request body.

:::::
::::::
:::::::

<span id="成功响应"></span>

## Successful response

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": 0,
  "data": {
    "workspace_id": "workspace_example",
    "connection_id": "connection_example",
    "status": "not_connected",
    "generation": 0,
    "revision": 0,
    "connection_version": 1
  }
}
```

:::::
:::::{tab-item} Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | 0 on success. |
| `data` | object | Data returned by this action. |
| `data.workspace_id` | string | Resource fields; see [common objects and states](objects.md). |
| `data.connection_id` | string | Resource fields; see [common objects and states](objects.md). |
| `data.status` | string | Current state; assess it using this page's conditions and common objects. |
| `data.generation` | integer | Authorization generation, used as expected_generation for disconnect. May be 0 before authorization. |
| `data.revision` | integer | Resource fields; see [common objects and states](objects.md). |
| `data.connection_version` | integer | Resource fields; see [common objects and states](objects.md). |

:::::
::::::
:::::::

<span id="错误响应"></span>

## Error responses

Handle business errors with numeric `code`, `message`, and `details.reason` separately from authorization-layer errors with string codes. See [errors and states](objects.md#error-responses). On state or version conflicts, read the current resource before changing identifiers or retrying writes.
