Terbitkan access token (client credentials)
Kredensial dikirim lewat Authorization: Basic base64(client_id:client_secret) (disarankan) atau field
client_id/client_secret di body. Body application/x-www-form-urlencoded (JSON juga diterima).
scope opsional: subset scope klien dipisah spasi; default semua scope klien. Token opaque, berlaku 3600 detik,
tidak ada refresh token. Batas laju 60 permintaan/menit/IP.
- Scope
- Autentikasi klien (Basic)
Body permintaan application/x-www-form-urlencoded
| Nama | Tipe | Keterangan |
|---|---|---|
| grant_typewajib | "client_credentials" | |
| scope | string | Subset scope dipisah spasi; default semua scope klien. |
| client_id | string | Alternatif Basic auth |
| client_secret | string | Alternatif Basic auth |
grant_type=client_credentials&scope=patients%3Aread+encounters%3AreadContoh kode
curl -X POST "https://api.medivana.cloud/api/v1/oauth/token" \
-u "$MEDIVANA_CLIENT_ID:$MEDIVANA_CLIENT_SECRET" \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'scope=patients:read encounters:read'const basic = Buffer.from(`${process.env.MEDIVANA_CLIENT_ID}:${process.env.MEDIVANA_CLIENT_SECRET}`).toString("base64");
const res = await fetch("https://api.medivana.cloud/api/v1/oauth/token", {
method: "POST",
headers: { Authorization: `Basic ${basic}` },
body: new URLSearchParams({
grant_type: "client_credentials",
scope: "patients:read encounters:read",
}),
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
const data = await res.json();import os
import requests
resp = requests.post(
"https://api.medivana.cloud/api/v1/oauth/token",
auth=(os.environ["MEDIVANA_CLIENT_ID"], os.environ["MEDIVANA_CLIENT_SECRET"]),
data={
"grant_type": "client_credentials",
"scope": "patients:read encounters:read",
},
timeout=30,
)
resp.raise_for_status()
data = resp.json()Respons
200Token terbitapplication/json
{
"access_token": "mdn_at_Q2xpZW50Q3JlZGVudGlhbHNDb250b2g",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "patients:read encounters:read"
}Skema 200
| Nama | Tipe | Keterangan |
|---|---|---|
| access_tokenwajib | string | |
| token_typewajib | "Bearer" | |
| expires_inwajib | integer | Detik |
| scopewajib | string | Scope yang diberikan, dipisah spasi |
Galat
- 400
invalid_request,unsupported_grant_type,invalid_scope(scope tidak diberikan ke klien), atauunauthorized_client(modul API tidak aktif di paket) - 401
invalid_client: client_id tidak dikenal, secret salah, atau klien dicabut - 429
rate-limited60 permintaan per menit per IP terlampaui