Create access token
curl --request POST \
--url https://auth.neuronsearchlab.com/oauth2/token \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=client_credentials \
--data 'scope=neuronsearchlab-api/read neuronsearchlab-api/write'import requests
url = "https://auth.neuronsearchlab.com/oauth2/token"
payload = {
"grant_type": "client_credentials",
"scope": "neuronsearchlab-api/read neuronsearchlab-api/write"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
grant_type: 'client_credentials',
scope: 'neuronsearchlab-api/read neuronsearchlab-api/write'
})
};
fetch('https://auth.neuronsearchlab.com/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://auth.neuronsearchlab.com/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&scope=neuronsearchlab-api%2Fread%20neuronsearchlab-api%2Fwrite",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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://auth.neuronsearchlab.com/oauth2/token"
payload := strings.NewReader("grant_type=client_credentials&scope=neuronsearchlab-api%2Fread%20neuronsearchlab-api%2Fwrite")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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://auth.neuronsearchlab.com/oauth2/token")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("grant_type=client_credentials&scope=neuronsearchlab-api%2Fread%20neuronsearchlab-api%2Fwrite")
.asString();require 'uri'
require 'net/http'
url = URI("https://auth.neuronsearchlab.com/oauth2/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "grant_type=client_credentials&scope=neuronsearchlab-api%2Fread%20neuronsearchlab-api%2Fwrite"
response = http.request(request)
puts response.read_body{
"access_token": "<token>",
"expires_in": 3600,
"token_type": "Bearer",
"scope": "neuronsearchlab-api/read neuronsearchlab-api/write"
}{
"error": "invalid_client",
"error_description": "<string>"
}{
"error": "invalid_client",
"error_description": "<string>"
}{
"error": "invalid_client",
"error_description": "<string>"
}Authentication
Create access token
Exchange SDK credentials for a short-lived access token.
POST
/
oauth2
/
token
Create access token
curl --request POST \
--url https://auth.neuronsearchlab.com/oauth2/token \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=client_credentials \
--data 'scope=neuronsearchlab-api/read neuronsearchlab-api/write'import requests
url = "https://auth.neuronsearchlab.com/oauth2/token"
payload = {
"grant_type": "client_credentials",
"scope": "neuronsearchlab-api/read neuronsearchlab-api/write"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
grant_type: 'client_credentials',
scope: 'neuronsearchlab-api/read neuronsearchlab-api/write'
})
};
fetch('https://auth.neuronsearchlab.com/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://auth.neuronsearchlab.com/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&scope=neuronsearchlab-api%2Fread%20neuronsearchlab-api%2Fwrite",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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://auth.neuronsearchlab.com/oauth2/token"
payload := strings.NewReader("grant_type=client_credentials&scope=neuronsearchlab-api%2Fread%20neuronsearchlab-api%2Fwrite")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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://auth.neuronsearchlab.com/oauth2/token")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("grant_type=client_credentials&scope=neuronsearchlab-api%2Fread%20neuronsearchlab-api%2Fwrite")
.asString();require 'uri'
require 'net/http'
url = URI("https://auth.neuronsearchlab.com/oauth2/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "grant_type=client_credentials&scope=neuronsearchlab-api%2Fread%20neuronsearchlab-api%2Fwrite"
response = http.request(request)
puts response.read_body{
"access_token": "<token>",
"expires_in": 3600,
"token_type": "Bearer",
"scope": "neuronsearchlab-api/read neuronsearchlab-api/write"
}{
"error": "invalid_client",
"error_description": "<string>"
}{
"error": "invalid_client",
"error_description": "<string>"
}{
"error": "invalid_client",
"error_description": "<string>"
}Endpoint
POST https://auth.neuronsearchlab.com/oauth2/token
Request
curl -X POST https://auth.neuronsearchlab.com/oauth2/token \
-H "Authorization: Basic <base64(client_id:client_secret)>" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&scope=neuronsearchlab-api/read%20neuronsearchlab-api/write"
| Field | Type | Required | Description |
|---|---|---|---|
grant_type | string | yes | Must be client_credentials. |
scope | string | no | Space-delimited scopes. Omit to use the scopes configured for the client. |
Response
{
"access_token": "<token>",
"expires_in": 3600,
"token_type": "Bearer",
"scope": "neuronsearchlab-api/read neuronsearchlab-api/write"
}
access_token as the Bearer token for Core API resource calls. expires_in is a lifetime in seconds; compute expires_at = now + expires_in in your token cache and refresh before that time.
Errors
| Status | Scenario |
|---|---|
400 | Unsupported grant type or malformed request body |
401 | Invalid client credentials |
429 | Token request rate limit exceeded |
Authorizations
HTTP Basic authentication using client_id:client_secret for token exchange.
Body
application/x-www-form-urlencoded
Was this page helpful?
⌘I

