跳到主要内容

3.4. 设备访问令牌请求 (Device Access Token Request)

向 user 显示 instruction 后, client 创建 access token request, 并将其发送到 token endpoint ([RFC6749] Section 3.2 定义), 其中 grant_typeurn:ietf:params:oauth:grant-type:device_code. 这是本规范创建的 extension grant type ([RFC6749] Section 4.5 定义), 带有以下 parameter:

grant_type

  • REQUIRED. value MUST 设置为 urn:ietf:params:oauth:grant-type:device_code.

device_code

  • REQUIRED. device verification code, 即 Section 3.2 定义的 device authorization response 中的 device_code.

client_id

  • 如果 client 未按 [RFC6749] Section 3.2.1 所述向 authorization server 进行 authentication, 则 REQUIRED. client identifier 如 [RFC6749] Section 2.2 所述.

例如, client 发出以下 HTTPS request, 换行仅用于显示:

POST /token HTTP/1.1
Host: server.example.com
Content-Type: application/x-www-form-urlencoded

grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code
&device_code=GmRhmhcxhwAzkoEqiMEg_DnyEysNkuNhszIySk9eS
&client_id=1406020730

如果 client 已被签发 client credential, 或被分配其他 authentication requirement, client MUST 按 [RFC6749] Section 3.2.1 所述向 authorization server 进行 authentication. 注意, 静态分发的 client credential 存在 security implication; 见 Section 5.6.

对此 request 的 response 在 Section 3.5 中定义. 与其他 OAuth grant type 不同, client 预期会根据 response 中的 error code 以 polling 方式重复尝试 access token request.