POST /v1/oauth/device/code
curl --request POST \
--url https://api.example.com/v1/oauth/device/code \
--header 'Content-Type: application/json' \
--data '
{
"client_id": "",
"scope": ""
}
'import requests
url = "https://api.example.com/v1/oauth/device/code"
payload = {
"client_id": "",
"scope": ""
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({client_id: '', scope: ''})
};
fetch('https://api.example.com/v1/oauth/device/code', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/oauth/device/code",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'client_id' => '',
'scope' => ''
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/oauth/device/code"
payload := strings.NewReader("{\n \"client_id\": \"\",\n \"scope\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/oauth/device/code")
.header("Content-Type", "application/json")
.body("{\n \"client_id\": \"\",\n \"scope\": \"\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/oauth/device/code")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"client_id\": \"\",\n \"scope\": \"\"\n}"
response = http.request(request)
puts response.read_body{
"device_code": "<string>",
"expires_in": 123,
"interval": 123,
"user_code": "<string>",
"verification_uri": "<string>",
"verification_uri_complete": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}OAuth
POST /v1/oauth/device/code
POST
/
v1
/
oauth
/
device
/
code
POST /v1/oauth/device/code
curl --request POST \
--url https://api.example.com/v1/oauth/device/code \
--header 'Content-Type: application/json' \
--data '
{
"client_id": "",
"scope": ""
}
'import requests
url = "https://api.example.com/v1/oauth/device/code"
payload = {
"client_id": "",
"scope": ""
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({client_id: '', scope: ''})
};
fetch('https://api.example.com/v1/oauth/device/code', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/oauth/device/code",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'client_id' => '',
'scope' => ''
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/oauth/device/code"
payload := strings.NewReader("{\n \"client_id\": \"\",\n \"scope\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/oauth/device/code")
.header("Content-Type", "application/json")
.body("{\n \"client_id\": \"\",\n \"scope\": \"\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/oauth/device/code")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"client_id\": \"\",\n \"scope\": \"\"\n}"
response = http.request(request)
puts response.read_body{
"device_code": "<string>",
"expires_in": 123,
"interval": 123,
"user_code": "<string>",
"verification_uri": "<string>",
"verification_uri_complete": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}请求体
application/jsonapplication/x-www-form-urlencoded
响应
Success
RFC 8628 §3.2. device_code is plaintext and exists only here.
The secret the device polls with.
Seconds.
The minimum seconds between polls.
The short code the person types, in the grouped form they read off the screen. Lookups normalize it, so any spelling with the right characters resolves.
The same page with the code already filled in, for a device that can show a QR code (RFC 8628 §3.3.1).