Reference
Authentication
OAuth2 client_credentials: an opaque token valid for one hour.
Request a token (client_credentials)
POST/v1/oauth/token
No token: it authenticates with the client_secret.
OAuth2 client_credentials. The token is opaque, lasts one hour and is revoked immediately when the client is deactivated.
Body application/x-www-form-urlencoded TokenRequest
grant_typestringrequiredPossible values:
client_credentialsclient_idstringrequiredclient_secretstringrequiredscopestringSpace-separated; a subset of the client’s. Without it, all of the client’s.
Responses
- 200
Token issued.
application/json
TokenResponse - 400
Malformed request or scope not allowed.
application/json
OAuthError - 401
Incorrect client or secret.
application/json
OAuthError
Request · sandbox
curl -X POST https://sandbox.api.safeonuba.com/v1/oauth/token \
-d grant_type=client_credentials \
-d client_id="$SAFEONUBA_CLIENT_ID" \
-d client_secret="$SAFEONUBA_CLIENT_SECRET" \
-d scope="alerts:read musters:read"const res = await fetch('https://sandbox.api.safeonuba.com/v1/oauth/token', {
method: 'POST',
body: new URLSearchParams({
grant_type: 'client_credentials',
client_id: process.env.SAFEONUBA_CLIENT_ID,
client_secret: process.env.SAFEONUBA_CLIENT_SECRET,
scope: 'alerts:read musters:read',
}),
});
const { access_token, expires_in } = await res.json();import os
import requests
res = requests.post(
"https://sandbox.api.safeonuba.com/v1/oauth/token",
data={
"grant_type": "client_credentials",
"client_id": os.environ["SAFEONUBA_CLIENT_ID"],
"client_secret": os.environ["SAFEONUBA_CLIENT_SECRET"],
"scope": "alerts:read musters:read",
},
timeout=10,
)
res.raise_for_status()
token = res.json()["access_token"]using System.Net.Http.Json;
using System.Text.Json;
using var http = new HttpClient();
var res = await http.PostAsync("https://sandbox.api.safeonuba.com/v1/oauth/token", new FormUrlEncodedContent(new Dictionary<string, string>
{
["grant_type"] = "client_credentials",
["client_id"] = Environment.GetEnvironmentVariable("SAFEONUBA_CLIENT_ID")!,
["client_secret"] = Environment.GetEnvironmentVariable("SAFEONUBA_CLIENT_SECRET")!,
["scope"] = "alerts:read musters:read",
}));
res.EnsureSuccessStatusCode();
var token = await res.Content.ReadFromJsonAsync<JsonElement>();Response 200
{
"access_token": "at_9c1e…",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "alerts:read alerts:write musters:read"
}