curl --request POST \
--url https://api.sandbox.nevermined.app/oauth/device_authorization \
--header 'Content-Type: application/json' \
--data '
{
"client_id": "fleet",
"agent_id": "agent-123",
"resource": "https://api.nevermined.app",
"scope": "openid"
}
'import requests
url = "https://api.sandbox.nevermined.app/oauth/device_authorization"
payload = {
"client_id": "fleet",
"agent_id": "agent-123",
"resource": "https://api.nevermined.app",
"scope": "openid"
}
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: 'fleet',
agent_id: 'agent-123',
resource: 'https://api.nevermined.app',
scope: 'openid'
})
};
fetch('https://api.sandbox.nevermined.app/oauth/device_authorization', 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.sandbox.nevermined.app/oauth/device_authorization",
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' => 'fleet',
'agent_id' => 'agent-123',
'resource' => 'https://api.nevermined.app',
'scope' => 'openid'
]),
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.sandbox.nevermined.app/oauth/device_authorization"
payload := strings.NewReader("{\n \"client_id\": \"fleet\",\n \"agent_id\": \"agent-123\",\n \"resource\": \"https://api.nevermined.app\",\n \"scope\": \"openid\"\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.sandbox.nevermined.app/oauth/device_authorization")
.header("Content-Type", "application/json")
.body("{\n \"client_id\": \"fleet\",\n \"agent_id\": \"agent-123\",\n \"resource\": \"https://api.nevermined.app\",\n \"scope\": \"openid\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.nevermined.app/oauth/device_authorization")
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\": \"fleet\",\n \"agent_id\": \"agent-123\",\n \"resource\": \"https://api.nevermined.app\",\n \"scope\": \"openid\"\n}"
response = http.request(request)
puts response.read_body{
"device_code": "<string>",
"user_code": "BCDF-GHJK",
"verification_uri": "https://nevermined.app/oauth/device",
"verification_uri_complete": "https://nevermined.app/oauth/device?user_code=BCDF-GHJK",
"expires_in": 600,
"interval": 5
}{
"code": "BCK.OAUTH.0016",
"message": "Unknown OAuth client",
"category": "auth",
"hint": "<string>",
"retryable": true,
"httpStatus": 400
}RFC 8628 device authorization request
Start the device flow. Requires a pre-registered client_id (BCK.OAUTH.0016) and an agent_id (absent → BCK.OAUTH.0018). Returns the device_code the agent polls with and the user_code the human approves.
curl --request POST \
--url https://api.sandbox.nevermined.app/oauth/device_authorization \
--header 'Content-Type: application/json' \
--data '
{
"client_id": "fleet",
"agent_id": "agent-123",
"resource": "https://api.nevermined.app",
"scope": "openid"
}
'import requests
url = "https://api.sandbox.nevermined.app/oauth/device_authorization"
payload = {
"client_id": "fleet",
"agent_id": "agent-123",
"resource": "https://api.nevermined.app",
"scope": "openid"
}
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: 'fleet',
agent_id: 'agent-123',
resource: 'https://api.nevermined.app',
scope: 'openid'
})
};
fetch('https://api.sandbox.nevermined.app/oauth/device_authorization', 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.sandbox.nevermined.app/oauth/device_authorization",
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' => 'fleet',
'agent_id' => 'agent-123',
'resource' => 'https://api.nevermined.app',
'scope' => 'openid'
]),
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.sandbox.nevermined.app/oauth/device_authorization"
payload := strings.NewReader("{\n \"client_id\": \"fleet\",\n \"agent_id\": \"agent-123\",\n \"resource\": \"https://api.nevermined.app\",\n \"scope\": \"openid\"\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.sandbox.nevermined.app/oauth/device_authorization")
.header("Content-Type", "application/json")
.body("{\n \"client_id\": \"fleet\",\n \"agent_id\": \"agent-123\",\n \"resource\": \"https://api.nevermined.app\",\n \"scope\": \"openid\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.nevermined.app/oauth/device_authorization")
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\": \"fleet\",\n \"agent_id\": \"agent-123\",\n \"resource\": \"https://api.nevermined.app\",\n \"scope\": \"openid\"\n}"
response = http.request(request)
puts response.read_body{
"device_code": "<string>",
"user_code": "BCDF-GHJK",
"verification_uri": "https://nevermined.app/oauth/device",
"verification_uri_complete": "https://nevermined.app/oauth/device?user_code=BCDF-GHJK",
"expires_in": 600,
"interval": 5
}{
"code": "BCK.OAUTH.0016",
"message": "Unknown OAuth client",
"category": "auth",
"hint": "<string>",
"retryable": true,
"httpStatus": 400
}Body
Pre-registered connector (unregistered → BCK.OAUTH.0016).
"fleet"
Target agent — required today (absent → BCK.OAUTH.0018).
"agent-123"
RFC 8707 resource (audience) — SELECTS the credential. For the usual device-flow goal (an NVM API key), either omit it or use this API's host, as in the example; a NON-API resource makes the exchange mint an x402 permission instead, which fails with BCK.OAUTH.0008 if the binding has no delegation.
"https://api.nevermined.app"
"openid"
Response
Device + user codes
Machine secret the agent polls with (opaque).
"BCDF-GHJK"
"https://nevermined.app/oauth/device"
"https://nevermined.app/oauth/device?user_code=BCDF-GHJK"
600
Minimum seconds between token polls.
5
Was this page helpful?