Skip to content

[POST] Client Credentials Access Token⚓︎

Use this request to obtain an access token to authenticate against the SmartDocumentor API.

We use the client credentials OAuth2.0 flow for authentication with external client applications.

To find out how you can obtain your own Client ID / Client Secret pair, check the Create Secrets section.

Re-using access tokens

While the API allows you to request as many access tokens as necessary, it is recommended to cache the access token for performance. Only request a new token once the previous one expires.

Client Credentials Access Token⚓︎

POST /connect/token

Body⚓︎

NameTypeDescription
grant_typeclient_credentialsThe grant type used to request the token. Always "client_credentials" as per the client credentials flow
scopeWebAPIAge The scope(s) used to request access. MUST always be "WebAPI".
client_id{your Client ID}Your Client ID, tied to your organization.
client_secret{your Client Secret}Your Client Secret, tied to your Client ID.

Example Request⚓︎

curl --location 'https://cloud.smartdocumentor.net/connect/token'
--header 'Content-Type: application/x-www-form-urlencoded'
--data-urlencode 'grant_type=client_credentials'
--data-urlencode 'scope=WebAPI'
--data-urlencode 'client_id={your Client ID}'
--data-urlencode 'client_secret={your Client Secret}'
client = new HttpClient();

var request = new HttpRequestMessage(HttpMethod.Post, "https://cloud.smartdocumentor.net/connect/token");

var collection = new List<KeyValuePair<string, string>>();
collection.Add(new("grant_type", "client_credentials"));
collection.Add(new("scope", "WebAPI"));
collection.Add(new("client_id", "{your Client ID}"));
collection.Add(new("client_secret", "{your Client Secret}"));

var content = new FormUrlEncodedContent(collection);
request.Content = content;

var response = await client.SendAsync(request);

response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
import requests

url = "https://cloud.smartdocumentor.net/connect/token"

client_id = {your Client ID}
client_secret = {your Client Secret}

payload = f'grant_type=client_credentials&scope=WebAPI&client_id={client_id}&client_secret={client_secret}'
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");

const urlencoded = new URLSearchParams();
urlencoded.append("grant_type", "client_credentials");
urlencoded.append("scope", "WebAPI");
urlencoded.append("client_id", {your Client ID});
urlencoded.append("client_secret", {your Client Secret});

const requestOptions = {
method: 'POST',
headers: myHeaders,
body: urlencoded,
redirect: 'follow'
};

fetch("https://cloud.smartdocumentor.net/connect/token", requestOptions)
    .then(response => response.text())
    .then(result => console.log(result))
    .catch(error => console.log('error', error));

Responses⚓︎

{
    "access_token": "your access token",
    "expires_in": 3600,
    "token_type": "Bearer",
    "scope": "WebAPI"
}

Response Body AccessTokenResponse

NameTypeDescription
access_tokenstringYour new access token. Add this to future requests as a Bearer token to perform authenticated requests against the API.
expires_inintegerTokens have a default expiration time of 3600 seconds (1 hour).
token_typestringThe type of token you issued. Always "Bearer".
scopestringThe scopes your access token has access to, seperated by spaces. Will always be "WebAPI".

{
    "error": "invalid_client"
}

Response Body

NameTypeDescription
errostringDetails about the error that occured.

Info

Getting invalid_client errors?

Check if your Client ID and Client Secret pair is correct and has not expired. Head to the Create Secrets section to learn more.