POST /oauth/device/authorize

OAuth 2.0 设备授权端点。设备发起授权请求,获取 device_code 和 user_code,用户随后在浏览器中输入 user_code 完成授权。公开端点,无需认证。参考:RFC 8628 §3.1 (Device Authorization Grant)。

OAuth None application/json

请求体

Schema: service-oauth/internal/handler/dto.DeviceAuthorizationRequest

字段类型必填示例约束描述
client_id string 是 app-123
scope string 否 openid profile

响应

状态描述Schema
200设备授权响应(含 device_code, user_code, verification_uri, expires_in, interval)service-oauth/internal/handler/dto.DeviceAuthorizationDetailResponse
400invalid_client:客户端未找到或未激活。参考:RFC 8628 §3.1。service-oauth/internal/handler/dto.OAuthErrorResponse
500server_error:创建设备授权失败。参考:RFC 8628 §3.1。service-oauth/internal/handler/dto.OAuthErrorResponse

引用的 Schema

service-oauth/internal/handler/dto.DeviceAuthorizationDetailResponse

字段类型必填示例约束描述
code integer 否
data service-oauth/internal/handler/dto.DeviceAuthorizationResponse 否
message string 否
timestamp string 否

service-oauth/internal/handler/dto.DeviceAuthorizationResponse

设备码授权响应(RFC 8628 §3.2)

字段类型必填示例约束描述
device_code string 否 7Q4mXp2vKd9Wn3sT8rY5uB1cF0jL6aH
expires_in integer 否 600
interval integer 否 5
user_code string 否 BDJW-DSXQ
verification_uri string 否 https://app.example.com/device

service-oauth/internal/handler/dto.OAuthErrorResponse

OAuth标准错误响应

字段类型必填示例约束描述
error string 否 invalid_request 错误码
error_description string 否 Missing required parameter 错误描述
error_uri string 否 https://docs.example.com/errors 错误URI
i18n_key string 否 error.oauth_invalid_request I18nKey 本地化键(AUTH-46①/U416):协议字段 error/error_description 保持 RFC 6749 §5.2 原样, 本字段是**附加**信息(omitempty;未知错误码不填),供前端/AI 客户端按键确定性渲染文案, 无需解析英文原文。仅出现在 JSON 错误体,不写入 302 错误重定向的查询串。
state string 否 state-123 状态