# OAuth2 错误：未授权的客户端

- **ID:** `api/oauth2-unauthorized-client`
- **领域:** api
- **类别:** auth_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

OAuth2 令牌请求中提供的 client_id 或 client_secret 未注册，或该客户端被禁止使用请求的授权类型。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| OAuth2 RFC 6749 | active | — | — |
| OAuth2 RFC 6750 | active | — | — |

## 解决方案

1. ```
   在 OAuth2 提供方的管理面板中验证 client_id 和 client_secret。确保客户端已启用且允许正确的授权类型（例如 authorization_code、client_credentials）。示例：curl -X POST https://auth.example.com/token -d 'grant_type=client_credentials&client_id=valid_client&client_secret=valid_secret'
   ```
2. ```
   查阅提供方的文档，确认是否需要指定的作用域或其他参数。添加缺失的作用域：POST /token 带上 scope=openid profile
   ```

## 无效尝试

- **** — Regenerating the client_secret without updating the application configuration will not resolve the issue if the client_id is incorrect or the grant type is not allowed. (40% 失败率)
- **** — Whitelisting the IP address of the client server does not address the root cause of an invalid client registration. (30% 失败率)
