client-py icon indicating copy to clipboard operation
client-py copied to clipboard

API/Oauth authentication example

Open atulkakrana opened this issue 5 years ago • 4 comments

Hi, It will help a lot if you can add some examples for FHIR client (client-py) on how we can authenticate sessions/calls from Python? For example - how can we use authenticate to access FHIR API: https://synthea.mitre.org/fhir-api ??

atulkakrana avatar Jul 08 '20 02:07 atulkakrana

@atulkakrana have you got any help on authenticate this? Also looking for the same.

EricPHassey avatar Apr 02 '21 01:04 EricPHassey

we need this badly I was about to write an issue, also against azure services

thanks

alihbuzaid avatar Jul 31 '22 09:07 alihbuzaid

I was also struggling to figure out, how to use user-password authentication with the fhirclient (specifically BasicAuth) until I came across the following stackoverflow answer. According to this, it is also possible to pass username and password to the url like this:

http://user:[email protected]/index.html

I then changed my settings-dictionary for the client initialization from:

settings = {
    "app_id": "some_app_id",
    "api_base": "https://my_fhir_server.com"}
smart = fhirclient.client.FHIRClient(settings=settings)

to

user = "username"
pw = "password"
settings = {
    "app_id": "some_app_id",
    "api_base": f"https://{user}:{pw}@my_fhir_server.com"}
smart = fhirclient.client.FHIRClient(settings=settings)

and it works as expected.

While this is a good enough workaround for my case, I only checked this for BasicAuth. And this might not be the most secure solution, but I am no expert on this.

In any case, it would be great to officially address different authentication methods like mentioned in #91 .

maxschloegel avatar Nov 15 '22 15:11 maxschloegel

@atulkakrana Do you have any update on this? Would love some help as I am facing the same issues

os-netizen avatar Jul 06 '23 18:07 os-netizen