Obtain access token
curl --request POST \
--url https://api.routera.io/oauth2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=client_credentials \
--data client_id=your-client-id \
--data client_secret=your-client-secret \
--data 'scope=routera-api/read routera-api/create routera-api/update routera-api/delete'import requests
url = "https://api.routera.io/oauth2/token"
payload = {
"grant_type": "client_credentials",
"client_id": "your-client-id",
"client_secret": "your-client-secret",
"scope": "routera-api/read routera-api/create routera-api/update routera-api/delete"
}
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: 'client_credentials',
client_id: 'your-client-id',
client_secret: 'your-client-secret',
scope: 'routera-api/read routera-api/create routera-api/update routera-api/delete'
})
};
fetch('https://api.routera.io/oauth2/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.routera.io/oauth2/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=client_credentials&client_id=your-client-id&client_secret=your-client-secret&scope=routera-api%2Fread%20routera-api%2Fcreate%20routera-api%2Fupdate%20routera-api%2Fdelete",
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.routera.io/oauth2/token"
payload := strings.NewReader("grant_type=client_credentials&client_id=your-client-id&client_secret=your-client-secret&scope=routera-api%2Fread%20routera-api%2Fcreate%20routera-api%2Fupdate%20routera-api%2Fdelete")
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.routera.io/oauth2/token")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("grant_type=client_credentials&client_id=your-client-id&client_secret=your-client-secret&scope=routera-api%2Fread%20routera-api%2Fcreate%20routera-api%2Fupdate%20routera-api%2Fdelete")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.routera.io/oauth2/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=client_credentials&client_id=your-client-id&client_secret=your-client-secret&scope=routera-api%2Fread%20routera-api%2Fcreate%20routera-api%2Fupdate%20routera-api%2Fdelete"
response = http.request(request)
puts response.read_body{
"access_token": "<string>",
"expires_in": 123,
"token_type": "Bearer"
}{
"message": "<string>",
"error": true,
"field": "<string>"
}{
"message": "<string>",
"error": true,
"field": "<string>"
}Authentication
Obtain access token
POST /oauth2/token — OAuth 2.0 client credentials
POST
/
oauth2
/
token
Obtain access token
curl --request POST \
--url https://api.routera.io/oauth2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=client_credentials \
--data client_id=your-client-id \
--data client_secret=your-client-secret \
--data 'scope=routera-api/read routera-api/create routera-api/update routera-api/delete'import requests
url = "https://api.routera.io/oauth2/token"
payload = {
"grant_type": "client_credentials",
"client_id": "your-client-id",
"client_secret": "your-client-secret",
"scope": "routera-api/read routera-api/create routera-api/update routera-api/delete"
}
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: 'client_credentials',
client_id: 'your-client-id',
client_secret: 'your-client-secret',
scope: 'routera-api/read routera-api/create routera-api/update routera-api/delete'
})
};
fetch('https://api.routera.io/oauth2/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.routera.io/oauth2/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=client_credentials&client_id=your-client-id&client_secret=your-client-secret&scope=routera-api%2Fread%20routera-api%2Fcreate%20routera-api%2Fupdate%20routera-api%2Fdelete",
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.routera.io/oauth2/token"
payload := strings.NewReader("grant_type=client_credentials&client_id=your-client-id&client_secret=your-client-secret&scope=routera-api%2Fread%20routera-api%2Fcreate%20routera-api%2Fupdate%20routera-api%2Fdelete")
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.routera.io/oauth2/token")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("grant_type=client_credentials&client_id=your-client-id&client_secret=your-client-secret&scope=routera-api%2Fread%20routera-api%2Fcreate%20routera-api%2Fupdate%20routera-api%2Fdelete")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.routera.io/oauth2/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=client_credentials&client_id=your-client-id&client_secret=your-client-secret&scope=routera-api%2Fread%20routera-api%2Fcreate%20routera-api%2Fupdate%20routera-api%2Fdelete"
response = http.request(request)
puts response.read_body{
"access_token": "<string>",
"expires_in": 123,
"token_type": "Bearer"
}{
"message": "<string>",
"error": true,
"field": "<string>"
}{
"message": "<string>",
"error": true,
"field": "<string>"
}Endpoint
POST https://api.routera.io/oauth2/token
/oauth2/tokenContent-Type:
application/x-www-form-urlencoded
This endpoint does not return a refresh token. When
expires_in elapses, call this endpoint again with the same client credentials.Request body
All parameters are sent as form fields (application/x-www-form-urlencoded). client_id, client_secret, and scope are required.
| Parameter | Required | Description |
|---|---|---|
grant_type | Yes | Must be client_credentials |
client_id | Yes | Your API client id |
client_secret | Yes | Your API client secret |
scope | Yes | Space-separated permissions (see below) |
Scopes
Request only the permissions you need, separated by spaces:| Scope | Access |
|---|---|
routera-api/read | Read |
routera-api/create | Create |
routera-api/update | Update |
routera-api/delete | Delete |
Example
curl -X POST 'https://api.routera.io/oauth2/token' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&scope=routera-api/read routera-api/create routera-api/update routera-api/delete'
Alternative: HTTP Basic
You may also send credentials in theAuthorization header instead of the form body:
Authorization: Basic base64(client_id:client_secret)
grant_type=client_credentials and scope.
Response
200 — Token issued{
"access_token": "eyJraWQiOi...",
"expires_in": 3600,
"token_type": "Bearer"
}
access_token on subsequent requests:
Authorization: Bearer eyJraWQiOi...
Errors
| Status | When |
|---|---|
400 | Missing or invalid grant_type |
401 | Invalid client_id or client_secret |
error, error_description).
Next step
After obtaining a token, see API introduction for object routes and response format.Body
application/x-www-form-urlencoded
Requires grant_type, client_id, client_secret, and scope as application/x-www-form-urlencoded fields.
Must be client_credentials
Available options:
client_credentials API client id (required)
Example:
"your-client-id"
API client secret (required)
Example:
"your-client-secret"
scope
string
default:routera-api/read routera-api/create routera-api/update routera-api/delete
required
Space-separated permissions: routera-api/read, routera-api/create, routera-api/update, routera-api/delete
Example:
"routera-api/read routera-api/create routera-api/update routera-api/delete"
Was this page helpful?
