medplum.setAccessToken followed by getProfile does...
# support
c
I have a small node server in which I would like to take the medplum access token and get their profile. To do this, I am calling
medplumClient.setAccessToken
then using the async getProfile call, but unfortunately it returns undefined. Am I missing something, or is there a different method I should be using for server-side interactions?
m
Hi Charlie! I took a look at
MedplumClient
and found that manually setting the access token clears any stored profile. The async call wasn't set up to update the profile if it wasn't cached in the client after a full login. I put up a small PR to update
client.getProfileAsync()
so it will go fetch the profile for you: https://github.com/medplum/medplum/pull/2978
c
@medplummatt Yeah, I think that change is wise. Based on the way bots are executed, I think this would effect them as well when you "runAsUser": https://github.com/medplum/medplum/blob/main/packages/server/src/fhir/operations/execute.ts#L420-L424
r
Closing this out as change is merged. Let us know how things go Charlie!
171 Views