Échanger le code d'appareil contre un jeton
curl --request POST \
--url https://dejavu.plus/api/v1/auth/device/token \
--header 'Content-Type: application/json' \
--data '
{
"device_code": "DEVICE_CODE_FROM_PREVIOUS_STEP",
"grant_type": "urn:ietf:params:oauth:grant-type:device_code"
}
'import requests
url = "https://dejavu.plus/api/v1/auth/device/token"
payload = {
"device_code": "DEVICE_CODE_FROM_PREVIOUS_STEP",
"grant_type": "urn:ietf:params:oauth:grant-type:device_code"
}
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({
device_code: 'DEVICE_CODE_FROM_PREVIOUS_STEP',
grant_type: 'urn:ietf:params:oauth:grant-type:device_code'
})
};
fetch('https://dejavu.plus/api/v1/auth/device/token', 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://dejavu.plus/api/v1/auth/device/token",
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([
'device_code' => 'DEVICE_CODE_FROM_PREVIOUS_STEP',
'grant_type' => 'urn:ietf:params:oauth:grant-type:device_code'
]),
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://dejavu.plus/api/v1/auth/device/token"
payload := strings.NewReader("{\n \"device_code\": \"DEVICE_CODE_FROM_PREVIOUS_STEP\",\n \"grant_type\": \"urn:ietf:params:oauth:grant-type:device_code\"\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://dejavu.plus/api/v1/auth/device/token")
.header("Content-Type", "application/json")
.body("{\n \"device_code\": \"DEVICE_CODE_FROM_PREVIOUS_STEP\",\n \"grant_type\": \"urn:ietf:params:oauth:grant-type:device_code\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dejavu.plus/api/v1/auth/device/token")
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 \"device_code\": \"DEVICE_CODE_FROM_PREVIOUS_STEP\",\n \"grant_type\": \"urn:ietf:params:oauth:grant-type:device_code\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "<string>",
"token_type": "Bearer",
"expires_in": 7776000
}Auth
Échanger le code d'appareil
Polling step to check whether the user has authorized the device.
POST
/
auth
/
device
/
token
Échanger le code d'appareil contre un jeton
curl --request POST \
--url https://dejavu.plus/api/v1/auth/device/token \
--header 'Content-Type: application/json' \
--data '
{
"device_code": "DEVICE_CODE_FROM_PREVIOUS_STEP",
"grant_type": "urn:ietf:params:oauth:grant-type:device_code"
}
'import requests
url = "https://dejavu.plus/api/v1/auth/device/token"
payload = {
"device_code": "DEVICE_CODE_FROM_PREVIOUS_STEP",
"grant_type": "urn:ietf:params:oauth:grant-type:device_code"
}
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({
device_code: 'DEVICE_CODE_FROM_PREVIOUS_STEP',
grant_type: 'urn:ietf:params:oauth:grant-type:device_code'
})
};
fetch('https://dejavu.plus/api/v1/auth/device/token', 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://dejavu.plus/api/v1/auth/device/token",
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([
'device_code' => 'DEVICE_CODE_FROM_PREVIOUS_STEP',
'grant_type' => 'urn:ietf:params:oauth:grant-type:device_code'
]),
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://dejavu.plus/api/v1/auth/device/token"
payload := strings.NewReader("{\n \"device_code\": \"DEVICE_CODE_FROM_PREVIOUS_STEP\",\n \"grant_type\": \"urn:ietf:params:oauth:grant-type:device_code\"\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://dejavu.plus/api/v1/auth/device/token")
.header("Content-Type", "application/json")
.body("{\n \"device_code\": \"DEVICE_CODE_FROM_PREVIOUS_STEP\",\n \"grant_type\": \"urn:ietf:params:oauth:grant-type:device_code\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dejavu.plus/api/v1/auth/device/token")
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 \"device_code\": \"DEVICE_CODE_FROM_PREVIOUS_STEP\",\n \"grant_type\": \"urn:ietf:params:oauth:grant-type:device_code\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "<string>",
"token_type": "Bearer",
"expires_in": 7776000
}Utilisation
Échange un device code approuvé contre un jeton. Cette opération est publique. Aucune clé API n’est requise pour cette opération.Exemple
curl -X POST -H "Content-Type: application/json" "https://dejavu.plus/api/v1/auth/device/token"
Paramètres et réponse
Les paramètres, schémas de requête et réponses sont définis par la spécification OpenAPI affichée sur cette page.Erreurs
Consultez Responses pour les codes et formats d’erreur propres à l’opération.Notes
Le flux utilisegrant_type=urn:ietf:params:oauth:grant-type:device_code.