NATSoauth.authorize.validate校验授权请求并签发授权码

apps/openapi 的 authorize 端点回源:校验应用状态、redirectUri 与 scope,落库授权范围并签发一次性授权码。

Request Payload

消息格式:JSON

NameData TypeRequiredDescription
appIdstringYes应用 ID
redirectUristringYes本次回调地址
scopesarrayYes请求的 scope
userIdstringYes授权用户 ID
type RequestBody = {
  /** 应用 ID */
  appId: string
  /** 本次回调地址 */
  redirectUri: string
  /** 请求的 scope */
  scopes: string[]
  /** 授权用户 ID */
  userId: string
}
{
  "appId": "01JD8SNST2N5U6X1BU9YBHK4C7J",
  "redirectUri": "https://analytics.xeegam.com/oauth/callback",
  "scopes": [
    "user:profile:read",
    "orgs:list"
  ],
  "userId": "01JD8SEGQ0P9N2XK4L7VDH3T6C"
}

Response Payload

回复使用统一信封 {id, code, messages, result},其 result:

NameData TypeRequiredDescription
codestringYes一次性授权码
grantIdstringYes授权记录 ID
expiresAtstringYes授权码过期时间
type ResponseBody = {
  /** 一次性授权码 */
  code: string
  /** 授权记录 ID */
  grantId: string
  /** 授权码过期时间 */
  expiresAt: string
}
{
  "code": "ac_5Fd83jK02mQ9wL7x",
  "grantId": "01JD8SNS9N1T4W0AT5X8AGN2Y6H",
  "expiresAt": "2026-10-14T12:10:00Z"
}

Response Code

回复使用统一信封 {id, code, messages, result},其 code 字段:

code Meaning Notes
0 成功 校验授权请求并签发授权码
2701 redirectUri 不在应用白名单
2702 应用未批准或已封禁
2704 请求 scope 超出应用已批准范围

Examples

{
  "appId": "01JD8SNST2N5U6X1BU9YBHK4C7J",
  "redirectUri": "https://analytics.xeegam.com/oauth/callback",
  "scopes": ["user:profile:read", "orgs:list"],
  "userId": "01JD8SEGQ0P9N2XK4L7VDH3T6C"
}
{
  "id": "01JD8SWSGR6T3UQ",
  "code": 0,
  "messages": [],
  "result": {
    "code": "ac_5Fd83jK02mQ9wL7x",
    "grantId": "01JD8SNS9N1T4W0AT5X8AGN2Y6H",
    "expiresAt": "2026-10-14T12:10:00Z"
  }
}