OAuthTokenData

@Serializable
data class OAuthTokenData(val accessToken: String, val expiresIn: Int, val tokenType: String, val scope: String? = null, val refreshToken: String? = null)

OAuth 令牌数据 包含 OAuth 访问令牌信息(OAuth 流程)

官方文档:vds-docs/VDS 账户/VDS 账户快速接入(OAuth).md

字段说明(对应官方 API 响应字段):

  • access_token: 访问令牌(OAuth 流程专用)

  • 用于访问受保护的用户资源

  • 通过 Authorization: Bearer 或 X-OAuth-Access-Token: 传递

  • expires_in: 有效期(秒),通常为 3600(1 小时)

  • token_type: 令牌类型,固定为 "Bearer"

  • scope: 授权的权限范围(可选)

  • 多个权限用空格分隔

  • 如 "user.profile user.email"

  • refresh_token: 刷新令牌(可选)

  • 用于在 access_token 过期后获取新的访问令牌

  • 仅在初次授权时返回,刷新令牌时可能轮换

  • 仅在 grant_type=authorization_code 时返回

响应示例:

{
"access_token": "eyJhbGciOiJIUzI1NiIs...",
"expires_in": 3600,
"token_type": "Bearer",
"scope": "user.profile",
"refresh_token": "dGhpcyBpcyBhIHJlZnJlc2g..."
}

Constructors

Link copied to clipboard
constructor(accessToken: String, expiresIn: Int, tokenType: String, scope: String? = null, refreshToken: String? = null)

Properties

Link copied to clipboard
@SerialName(value = "access_token")
val accessToken: String

访问令牌(OAuth 流程专用)

Link copied to clipboard
@SerialName(value = "expires_in")
val expiresIn: Int

有效期(秒)

Link copied to clipboard
@SerialName(value = "refresh_token")
val refreshToken: String? = null

刷新令牌,用于获取新的访问令牌

Link copied to clipboard
val scope: String? = null

授权的权限范围

Link copied to clipboard
@SerialName(value = "token_type")
val tokenType: String

令牌类型