Request an access token
Solicitar un token de acceso
Exchanges your client credentials for an access token. Send the body form-encoded (application/x-www-form-urlencoded); JSON bodies are rejected.
Intercambia tus credenciales de cliente por un token de acceso. Envía el cuerpo codificado como formulario (application/x-www-form-urlencoded); los cuerpos JSON se rechazan.
- grant_typestringRequiredObligatorio
Always
client_credentials.Siempre
client_credentials. - client_idstring
Your client ID. Required unless you send the credentials as HTTP Basic (
Authorization: Basic base64(client_id:client_secret)), which is what the cURL example does.Tu ID de cliente. Obligatorio a menos que envíes las credenciales como HTTP Basic (
Authorization: Basic base64(client_id:client_secret)), que es lo que hace el ejemplo de cURL. - client_secretstring
Your client secret. Required unless you send it as HTTP Basic.
Tu secreto de cliente. Obligatorio a menos que lo envíes como HTTP Basic.
- access_tokenstring
A signed JWT. Send it as
Authorization: Bearer <access_token>.Un JWT firmado. Envíalo como
Authorization: Bearer <access_token>. - token_typestring
Always
Bearer.Siempre
Bearer. - expires_ininteger
Seconds until the token expires. Normally
3600(one hour).Segundos hasta que expire el token. Normalmente
3600(una hora). - scopestring
Always
openid.Siempre
openid. - projectReference
Your organization's project. Every request made with this token is limited to it.
El proyecto de tu organización. Toda solicitud hecha con este token se limita a él.
- profileReference
Your API client, as
ClientApplication/<client_id>.Tu cliente de API, como
ClientApplication/<client_id>. - id_tokenstring
An OpenID Connect ID token. You don't need it for API calls.
Un token de ID de OpenID Connect. No lo necesitas para las llamadas a la API.
There is no refresh token. When a token expires, request a new one the same way.
No hay refresh token. Cuando un token expira, solicita uno nuevo de la misma forma.
curl "https://api.medplum.konko.ai/oauth2/token" \
-u "$CLIENT_ID:$CLIENT_SECRET" \
--data-urlencode "grant_type=client_credentials"import requests
resp = requests.post(
"https://api.medplum.konko.ai/oauth2/token",
auth=(CLIENT_ID, CLIENT_SECRET),
data={"grant_type": "client_credentials"},
timeout=30,
)
resp.raise_for_status()
data = resp.json()const res = await fetch('https://api.medplum.konko.ai/oauth2/token', {
method: 'POST',
headers: {
Authorization: `Basic ${btoa(`${CLIENT_ID}:${CLIENT_SECRET}`)}`,
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({ grant_type: 'client_credentials' }),
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
const data = await res.json();{
"token_type": "Bearer",
"expires_in": 3600,
"scope": "openid",
"id_token": "eyJhbGciOiJFUzI1NiIsImtpZCI6IjRmM2E…",
"access_token": "eyJhbGciOiJFUzI1NiIsImtpZCI6IjRmM2E4YjE2In0.eyJjbGllbnRfaWQiOiI3YzFlOWI1Mi…",
"project": {
"reference": "Project/0f5c3d2a-7b1e-4c8f-9a6d-2e4b8c1f7a90"
},
"profile": {
"reference": "ClientApplication/7c1e9b52-3a4d-4f8e-b6c2-91d0a5e3f7b4"
}
}