Skip to main content
Glama
rotate-client-secret.ts1.41 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import { MedplumClient } from '@medplum/core'; import type { ClientApplication } from '@medplum/fhirtypes'; import { randomUUID } from 'node:crypto'; const medplum = new MedplumClient(); const clientApplication: ClientApplication & { id: string } = { resourceType: 'ClientApplication', id: randomUUID(), secret: randomUUID(), }; // start-block rotate // First, rotate the initial secret const rotatedClient: ClientApplication = await medplum.post( medplum.fhirUrl('ClientApplication', clientApplication.id, '$rotate-secret'), { resourceType: 'Parameters', parameter: [{ name: 'secret', valueString: clientApplication.secret }], } ); console.log('Client secret rotated; new secret is:', rotatedClient.secret); console.log('Previous secret is still available for use:', rotatedClient.retiringSecret); // At this point, existing application instances should be updated to use the new secret // Once all use of the old (retiring) secret is resolved, rotate it out of service await medplum.post(medplum.fhirUrl('ClientApplication', clientApplication.id, '$rotate-secret'), { resourceType: 'Parameters', parameter: [{ name: 'retiringSecret', valueString: rotatedClient.retiringSecret }], }); // Now only the newly generated secret value will be valid // end-block rotate

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/medplum/medplum'

If you have feedback or need assistance with the MCP directory API, please join our Discord server