跳到主要内容

3.2. 设备授权响应 (Device Authorization Response)

作为 response, authorization server 生成一个唯一 device verification code 和一个 end-user code. 它们在有限时间内有效, 并使用 application/json format [RFC8259] 以 200 (OK) status code 将其包含在 HTTP response body 中. response 包含以下 parameter:

device_code

  • REQUIRED. device verification code.

user_code

  • REQUIRED. end-user verification code.

verification_uri

  • REQUIRED. authorization server 上的 end-user verification URI. URI 应简短且易记, 因为 end user 会被要求手动将其输入到 user agent 中.

verification_uri_complete

  • OPTIONAL. 包含 user_code, 或包含与 user_code 具有相同功能的其他信息的 verification URI, 设计用于 non-textual transmission.

expires_in

  • REQUIRED. device_codeuser_code 的 lifetime, 以秒为单位.

interval

  • OPTIONAL. client 在向 token endpoint 发出 polling request 之间 SHOULD 等待的最短时间, 以秒为单位. 如果未提供 value, client MUST 使用 5 作为默认值.

例如:

HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store

{
"device_code": "GmRhmhcxhwAzkoEqiMEg_DnyEysNkuNhszIySk9eS",
"user_code": "WDJB-MJHT",
"verification_uri": "https://example.com/device",
"verification_uri_complete":
"https://example.com/device?user_code=WDJB-MJHT",
"expires_in": 1800,
"interval": 5
}

如果发生 error, 例如 client 配置无效, authorization server 按 [RFC6749] Section 5.2 中 token endpoint 指定的方式响应.