Request Access Token
curl --request POST \
--url https://api.dashboard.knotapi.com/oauth/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=urn:ietf:params:oauth:grant-type:device_code \
--data client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c \
--data device_code=def50200a1b2c3d4e5f6import requests
url = "https://api.dashboard.knotapi.com/oauth/token"
payload = {
"grant_type": "urn:ietf:params:oauth:grant-type:device_code",
"client_id": "9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c",
"device_code": "def50200a1b2c3d4e5f6"
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
client_id: '9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c',
device_code: 'def50200a1b2c3d4e5f6'
})
};
fetch('https://api.dashboard.knotapi.com/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.dashboard.knotapi.com/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 => "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code&client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c&device_code=def50200a1b2c3d4e5f6",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded"
],
]);
$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.dashboard.knotapi.com/oauth/token"
payload := strings.NewReader("grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code&client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c&device_code=def50200a1b2c3d4e5f6")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
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.dashboard.knotapi.com/oauth/token")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code&client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c&device_code=def50200a1b2c3d4e5f6")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dashboard.knotapi.com/oauth/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code&client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c&device_code=def50200a1b2c3d4e5f6"
response = http.request(request)
puts response.read_body{
"token_type": "Bearer",
"expires_in": 900,
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiI5ZjNjMmExZSJ9.c2lnbmF0dXJl"
}Agent Authorization
Request Access Token
Exchange a device_code for an access token once the user approves the request.
POST
/
oauth
/
token
Request Access Token
curl --request POST \
--url https://api.dashboard.knotapi.com/oauth/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=urn:ietf:params:oauth:grant-type:device_code \
--data client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c \
--data device_code=def50200a1b2c3d4e5f6import requests
url = "https://api.dashboard.knotapi.com/oauth/token"
payload = {
"grant_type": "urn:ietf:params:oauth:grant-type:device_code",
"client_id": "9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c",
"device_code": "def50200a1b2c3d4e5f6"
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
client_id: '9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c',
device_code: 'def50200a1b2c3d4e5f6'
})
};
fetch('https://api.dashboard.knotapi.com/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.dashboard.knotapi.com/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 => "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code&client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c&device_code=def50200a1b2c3d4e5f6",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded"
],
]);
$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.dashboard.knotapi.com/oauth/token"
payload := strings.NewReader("grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code&client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c&device_code=def50200a1b2c3d4e5f6")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
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.dashboard.knotapi.com/oauth/token")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code&client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c&device_code=def50200a1b2c3d4e5f6")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dashboard.knotapi.com/oauth/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code&client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c&device_code=def50200a1b2c3d4e5f6"
response = http.request(request)
puts response.read_body{
"token_type": "Bearer",
"expires_in": 900,
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiI5ZjNjMmExZSJ9.c2lnbmF0dXJl"
}Body
application/x-www-form-urlencoded
The input parameters required for requesting an access token.
The grant type. Must be urn:ietf:params:oauth:grant-type:device_code.
Available options:
urn:ietf:params:oauth:grant-type:device_code Example:
"urn:ietf:params:oauth:grant-type:device_code"
The same client ID you sent to Request Device Code.
Example:
"9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c"
The device_code from Request Device Code.
Example:
"def50200a1b2c3d4e5f6"
Was this page helpful?