JT
08/15/2025, 5:55 AMMaddy
08/15/2025, 10:08 PMJT
08/15/2025, 11:22 PMimport { MedplumClient } from "@medplum/core";
async function testMedplumConnection() {
console.log('š Testing Medplum FHIR Server Connection...\n');
// First, let's check server health
try {
const response = await fetch('http://localhost:8103/healthcheck');
const health = await response.json();
console.log('ā
Server health check:', health);
} catch (healthError) {
console.error('ā Server not reachable:', healthError.message);
return;
}
// Test the FHIR base URL without authentication first
console.log('\n--- Testing FHIR Server Access ---');
try {
const medplumClient = new MedplumClient({
baseUrl: 'http://localhost:8103/'
});
await medplumClient.startClientLogin(
'2a4b77f2-4d4e-43c6-9b01-330eb5ca772f', // from docker-compose.yml
'top_secret' // added MEDPLUM_ADMIN_CLIENT_SECRET env
);
console.log(`Client credentials authentication ${medplumClient.isAuthenticated() ? 'successful' : 'failed'} `);
} catch (error) {
console.error('ā Error connecting to FHIR server:', error.message);
if (error.outcome) {
console.error('Error details:', JSON.stringify(error.outcome, null, 2));
}
}
}
// Run the test
testMedplumConnection().catch(console.error);
I added a MEDPLUM_ADMIN_CLIENT_SECRET to test if it would work but it didnt. is there a way for me to connect to the fhir server without needing the medplum app UI?finnbergquist
08/18/2025, 1:16 PMJT
08/18/2025, 1:23 PMfinnbergquist
08/18/2025, 2:13 PMtry {
const medplumClient = new MedplumClient({
baseUrl: 'http://localhost:8103/'
});
await medplumClient.startClientLogin(
'2a4b77f2-4d4e-43c6-9b01-330eb5ca772f', // from docker-compose.yml
'top_secret' // added MEDPLUM_ADMIN_CLIENT_SECRET env
);JT
08/19/2025, 2:43 AMnpx tsx test-tmp.ts
š Testing Medplum FHIR Server Connection...
ā
Server health check: {
ok: true,
version: '4.3.8-5d2307796',
platform: 'linux',
runtime: 'v20.19.4',
postgres: true,
redis: true
}
--- Testing FHIR Server Access ---
ā Error connecting to FHIR server: Failed to fetch tokens
Error details: {
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "invalid",
"details": {
"text": "Failed to fetch tokens"
}
}
]
}finnbergquist
08/19/2025, 7:56 PMcurl -X POST http://localhost:8103/oauth2/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=$MY_CLIENT_ID&client_secret=$MY_CLIENT_SECRET"finnbergquist
08/19/2025, 7:58 PMJT
08/20/2025, 12:47 AMfinnbergquist
08/20/2025, 4:34 PMJT
08/20/2025, 5:04 PMfinnbergquist
08/20/2025, 5:56 PM