curl --request POST \
--url https://api.sandbox.nevermined.app/oauth/token \
--header 'Content-Type: application/json' \
--data '
{
"grant_type": "authorization_code",
"client_id": "fleet",
"code": "<string>",
"redirect_uri": "cursor://oauth/callback",
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
"device_code": "<string>",
"refresh_token": "nvm_rt_Zm9vYmFy…",
"resource": "https://mcp-server.example.com"
}
'import requests
url = "https://api.sandbox.nevermined.app/oauth/token"
payload = {
"grant_type": "authorization_code",
"client_id": "fleet",
"code": "<string>",
"redirect_uri": "cursor://oauth/callback",
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
"device_code": "<string>",
"refresh_token": "nvm_rt_Zm9vYmFy…",
"resource": "https://mcp-server.example.com"
}
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({
grant_type: 'authorization_code',
client_id: 'fleet',
code: '<string>',
redirect_uri: 'cursor://oauth/callback',
code_verifier: 'dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk',
device_code: '<string>',
refresh_token: 'nvm_rt_Zm9vYmFy…',
resource: 'https://mcp-server.example.com'
})
};
fetch('https://api.sandbox.nevermined.app/oauth/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://api.sandbox.nevermined.app/oauth/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([
'grant_type' => 'authorization_code',
'client_id' => 'fleet',
'code' => '<string>',
'redirect_uri' => 'cursor://oauth/callback',
'code_verifier' => 'dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk',
'device_code' => '<string>',
'refresh_token' => 'nvm_rt_Zm9vYmFy…',
'resource' => 'https://mcp-server.example.com'
]),
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/token"
payload := strings.NewReader("{\n \"grant_type\": \"authorization_code\",\n \"client_id\": \"fleet\",\n \"code\": \"<string>\",\n \"redirect_uri\": \"cursor://oauth/callback\",\n \"code_verifier\": \"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\",\n \"device_code\": \"<string>\",\n \"refresh_token\": \"nvm_rt_Zm9vYmFy…\",\n \"resource\": \"https://mcp-server.example.com\"\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/token")
.header("Content-Type", "application/json")
.body("{\n \"grant_type\": \"authorization_code\",\n \"client_id\": \"fleet\",\n \"code\": \"<string>\",\n \"redirect_uri\": \"cursor://oauth/callback\",\n \"code_verifier\": \"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\",\n \"device_code\": \"<string>\",\n \"refresh_token\": \"nvm_rt_Zm9vYmFy…\",\n \"resource\": \"https://mcp-server.example.com\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.nevermined.app/oauth/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 \"grant_type\": \"authorization_code\",\n \"client_id\": \"fleet\",\n \"code\": \"<string>\",\n \"redirect_uri\": \"cursor://oauth/callback\",\n \"code_verifier\": \"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\",\n \"device_code\": \"<string>\",\n \"refresh_token\": \"nvm_rt_Zm9vYmFy…\",\n \"resource\": \"https://mcp-server.example.com\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "sandbox:eyJhbGciOiJFUzI1NksifQ…",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "nvm_rt_Zm9vYmFy…",
"scope": "openid"
}{
"error": "authorization_pending",
"error_description": "<string>"
}Exchange a code, device_code, or refresh_token for a credential
One endpoint, three grants. The grant only selects HOW the exchange happens; the credential type is selected by the resource (RFC 8707) and the binding, not the grant: an account_access consent always yields an NVM API key; otherwise a resource matching this API’s host yields an NVM API key and any other resource yields an x402 payment permission; with no resource, a delegation-backed binding yields an x402 permission and a plan-only binding yields an NVM API key. Device-flow polling returns a top-level error: authorization_pending, slow_down (add 5s to your interval), access_denied, expired_token. Honour the interval — this endpoint is rate-limited (~60/min per client IP for device polls, shared across concurrent ceremonies from the same address), so a real HTTP 429 (distinct from the slow_down grant error) is reachable under a tight poll loop.
curl --request POST \
--url https://api.sandbox.nevermined.app/oauth/token \
--header 'Content-Type: application/json' \
--data '
{
"grant_type": "authorization_code",
"client_id": "fleet",
"code": "<string>",
"redirect_uri": "cursor://oauth/callback",
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
"device_code": "<string>",
"refresh_token": "nvm_rt_Zm9vYmFy…",
"resource": "https://mcp-server.example.com"
}
'import requests
url = "https://api.sandbox.nevermined.app/oauth/token"
payload = {
"grant_type": "authorization_code",
"client_id": "fleet",
"code": "<string>",
"redirect_uri": "cursor://oauth/callback",
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
"device_code": "<string>",
"refresh_token": "nvm_rt_Zm9vYmFy…",
"resource": "https://mcp-server.example.com"
}
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({
grant_type: 'authorization_code',
client_id: 'fleet',
code: '<string>',
redirect_uri: 'cursor://oauth/callback',
code_verifier: 'dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk',
device_code: '<string>',
refresh_token: 'nvm_rt_Zm9vYmFy…',
resource: 'https://mcp-server.example.com'
})
};
fetch('https://api.sandbox.nevermined.app/oauth/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://api.sandbox.nevermined.app/oauth/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([
'grant_type' => 'authorization_code',
'client_id' => 'fleet',
'code' => '<string>',
'redirect_uri' => 'cursor://oauth/callback',
'code_verifier' => 'dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk',
'device_code' => '<string>',
'refresh_token' => 'nvm_rt_Zm9vYmFy…',
'resource' => 'https://mcp-server.example.com'
]),
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/token"
payload := strings.NewReader("{\n \"grant_type\": \"authorization_code\",\n \"client_id\": \"fleet\",\n \"code\": \"<string>\",\n \"redirect_uri\": \"cursor://oauth/callback\",\n \"code_verifier\": \"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\",\n \"device_code\": \"<string>\",\n \"refresh_token\": \"nvm_rt_Zm9vYmFy…\",\n \"resource\": \"https://mcp-server.example.com\"\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/token")
.header("Content-Type", "application/json")
.body("{\n \"grant_type\": \"authorization_code\",\n \"client_id\": \"fleet\",\n \"code\": \"<string>\",\n \"redirect_uri\": \"cursor://oauth/callback\",\n \"code_verifier\": \"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\",\n \"device_code\": \"<string>\",\n \"refresh_token\": \"nvm_rt_Zm9vYmFy…\",\n \"resource\": \"https://mcp-server.example.com\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.nevermined.app/oauth/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 \"grant_type\": \"authorization_code\",\n \"client_id\": \"fleet\",\n \"code\": \"<string>\",\n \"redirect_uri\": \"cursor://oauth/callback\",\n \"code_verifier\": \"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\",\n \"device_code\": \"<string>\",\n \"refresh_token\": \"nvm_rt_Zm9vYmFy…\",\n \"resource\": \"https://mcp-server.example.com\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "sandbox:eyJhbGciOiJFUzI1NksifQ…",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "nvm_rt_Zm9vYmFy…",
"scope": "openid"
}{
"error": "authorization_pending",
"error_description": "<string>"
}Body
authorization_code, refresh_token, urn:ietf:params:oauth:grant-type:device_code "authorization_code"
"fleet"
Required for authorization_code.
Required for authorization_code — must match the authorize request.
"cursor://oauth/callback"
PKCE verifier. Required for authorization_code.
"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
Required for the device_code grant.
Required for refresh_token.
"nvm_rt_Zm9vYmFy…"
RFC 8707 resource (audience). SELECTS the credential type on the authorization_code and device_code exchanges (this API's host → NVM API key; any other → x402 permission). On refresh_token it does NOT select: the credential is re-derived from the binding, and a resource here is only validated against the one bound at authorize (mismatch → BCK.OAUTH.0005) — it cannot re-target the credential.
"https://mcp-server.example.com"
Response
The minted credential
The credential selected by the resource/binding (see the endpoint description), NOT by the grant: an NVM API key (environment-prefixed, e.g. sandbox:… / live:…, as in this example) or an x402 payment permission (a JWT, NOT environment-prefixed).
"sandbox:eyJhbGciOiJFUzI1NksifQ…"
Bearer "Bearer"
3600
"nvm_rt_Zm9vYmFy…"
"openid"
Was this page helpful?