# 获取调用方信息

使用 /openapi/profile 验证 Access Token、接口登记和应用授权。

import ApiDebugger from '../../../components/ApiDebugger.astro';

## 接口信息

| 项目 | 值 |
| --- | --- |
| 请求方法 | `GET` |
| 请求 URL | `https://backend.biotech-mkt.com/openapi/profile` |
| 接口路径 | `/openapi/profile` |
| 认证方式 | Bearer Access Token |
| 权限要求 | 接口需启用并授权给当前应用 |
| 频控 | 按应用与接口配置 |

<ApiDebugger preset="profile" lang="zh" />

该接口用于联调诊断，返回当前 Access Token 对应的应用和请求上下文。

## 请求参数

需要 Access Token，并且平台管理员必须将该接口登记、启用并授权给当前应用。

该接口没有查询参数或请求体，只需要以下请求头：

| 请求头          | 类型   | 必填 | 说明                    |
| --------------- | ------ | ---- | ----------------------- |
| `Authorization` | string | 是   | `Bearer <access_token>` |

## 请求示例

```bash
curl "https://backend.biotech-mkt.com/openapi/profile" \
  --header "Authorization: Bearer $OPENAPI_ACCESS_TOKEN"
```

## 应答字段

| 字段                | 返回类型 | 说明                          |
| ------------------- | -------- | ----------------------------- |
| `code`              | integer  | 业务状态码，成功时为 `200`    |
| `message`           | string   | 响应消息                      |
| `data`              | object   | 调用方上下文                  |
| `app_id`            | integer  | OpenAPI 应用内部 ID           |
| `app_key`           | string   | 当前应用的 App Key            |
| `app_name`          | string   | 当前应用名称                  |
| `token_id`          | integer  | 当前令牌记录 ID，不是完整令牌 |
| `access_expires_at` | string   | Access Token 绝对过期时间     |
| `request_method`    | string   | 当前请求方法                  |
| `request_path`      | string   | 当前请求路径                  |

## 应答示例

```json
{
  "code": 200,
  "message": "成功",
  "data": {
    "app_id": 1,
    "app_key": "ak_xxx",
    "app_name": "订单数据应用",
    "token_id": 12,
    "access_expires_at": "2026-08-27 12:00:00",
    "request_method": "GET",
    "request_path": "/openapi/profile"
  }
}
```

## 错误码与频控

该接口可能返回 `401`、`403`、`404`、`405`、`429` 或 `503`。频控按“应用 ID + 接口 ID”独立计数；具体处理方式和响应头见[错误与频控](/guides/errors-rate-limits)。

## 接入验收

首次接入时应确认：

1. HTTP 状态码和响应 `code` 都是 `200`。
2. `app_key` 与平台交付的应用一致。
3. `request_method` 为 `GET`，`request_path` 为 `/openapi/profile`。
4. 响应包含 `X-Request-Id` 和当前接口的频控状态头。
