# 读取 OAuth 授权服务元数据

发现授权、客户端注册和令牌地址，以及授权类型和 PKCE 要求。

GET `/.well-known/oauth-authorization-server`

- **认证** 公开，无需登录。
- **成功状态** `200`

## 请求参数

此操作无需提交参数。

## 请求示例

**cURL**

```bash
curl -i -X GET 'https://social2api.com/.well-known/oauth-authorization-server'
```

**Python**

```python
from urllib.error import HTTPError
from urllib.request import Request, urlopen

request = Request(
    "https://social2api.com/.well-known/oauth-authorization-server",
    method="GET",
)
send = urlopen
try:
    with send(request) as response:
        print(response.status, response.read().decode("utf-8"))
except HTTPError as error:
    print(error.code, error.read().decode("utf-8"))
```

**JavaScript**

```javascript
const response = await fetch("/.well-known/oauth-authorization-server", {
  method: "GET",
});
console.log(response.status, await response.text());
```

## 响应

**200 · 示例响应**

```json
{
  "issuer": "https://social2api.com",
  "authorization_endpoint": "https://social2api.com/oauth/authorize",
  "token_endpoint": "https://social2api.com/oauth/token",
  "registration_endpoint": "https://social2api.com/oauth/register",
  "response_types_supported": [
    "code"
  ],
  "grant_types_supported": [
    "authorization_code",
    "refresh_token"
  ],
  "code_challenge_methods_supported": [
    "S256"
  ],
  "token_endpoint_auth_methods_supported": [
    "none",
    "client_secret_basic",
    "client_secret_post"
  ],
  "scopes_supported": [
    "mcp:tools"
  ],
  "authorization_response_iss_parameter_supported": true
}
```

**错误示例**

```json
{
  "error": "invalid_request"
}
```

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `issuer` | URI | 该 OAuth 服务的签发者标识。 |
| `authorization_endpoint` | URI | 浏览器授权地址。 |
| `token_endpoint` | URI | 兑换和刷新令牌的地址。 |
| `registration_endpoint` | URI | 客户端动态注册地址。 |
| `response_types_supported` | string\[\] | 接受的授权响应类型。 |
| `grant_types_supported` | string\[\] | 支持授权码和刷新令牌授权。 |
| `code_challenge_methods_supported` | string\[\] | PKCE 使用 S256。 |
| `token_endpoint_auth_methods_supported` | string\[\] | 令牌地址支持的客户端认证方式。 |
| `scopes_supported` | string\[\] | 服务可用的授权范围。 |
| `authorization_response_iss_parameter_supported` | boolean | 授权回调是否提供 iss 签发者参数。 |

## 错误状态

| HTTP | 原因与处理 |
| --- | --- |
| `405` | 请求方法不受支持。 |
| `500` | 授权服务暂时不可用。 |

## 同组接口

-   [GET 检查数据源配置](<https://social2api.com/docs/api/status/>)
-   [POST 运行取数任务](<https://social2api.com/docs/api/run/>)
-   [POST 调用 MCP 服务](<https://social2api.com/docs/api/mcp/>)
-   [GET 读取 OAuth 受保护资源元数据](<https://social2api.com/docs/api/oauth-resource-metadata/>)
-   [GET 读取 MCP 资源的 OAuth 元数据](<https://social2api.com/docs/api/oauth-mcp-metadata/>)
-   [POST 注册 MCP OAuth 客户端](<https://social2api.com/docs/api/oauth-register/>)
-   [GET 启动 MCP OAuth 授权](<https://social2api.com/docs/api/oauth-authorize-start/>)
-   [POST 提交 MCP OAuth 授权决定](<https://social2api.com/docs/api/oauth-authorize-consent/>)
-   [POST 兑换或刷新 MCP OAuth 令牌](<https://social2api.com/docs/api/oauth-token/>)

规范页面：<https://social2api.com/docs/api/oauth-server-metadata/>
