Authentication

Looking through the documentation, I did not see any section on authenticating to the fhir api. I wanted to test out a few of the sample requests but I am not sure the auth (0auth2 probably?).

When popping the sample requests into the browser, I am still getting 401 when entering my basic credentials used to sign up.

Any help would be appreciated!

Thanks!

Hi Jesse,

It should just be a simple authentication with your LOINC username and password. As you are posting to the forum, I assume you are able to log in to loinc.org so surely it’s not a password error. I’d suggest trying a cURL command to issue an authenticated request. It will prompt for a password.

curl -X GET -u myloincusername 'https://fhir.loinc.org/CodeSystem/$lookup?system=http://loinc.org&code=4544-3' --header 'Content-Type:application/fhir+json'

Please let us know whether or not you are able to get it work.

When I do that curl request I still get the 401, I’ve even updated my password and tried again:

<html>

<head><title>401 Authorization Required</title></head>

<body bgcolor=“white”>

<center><h1>401 Authorization Required</h1></center>

<hr><center>nginx/1.15.1</center>

</body>

</html>

Jesse,

I apologize for the problems. I am unable to reproduce this error. I have tried with a number existing accounts and created a new one specifically to test. All worked successfully with the previous curl command.

Can I have your permission to change the password on your CragVFX account so I may test it directly? (You can update it thereafter, of course.) We did recently change our authentication storage so there’s a chance there could be something amiss with your account.

Yes, go for it! Thanks for digging in Tim!

Jesse,

I was able to get that cURL command to work with your username and a new password. I tried from multiple hosts. I’m going to email you the new password so you may try yourself. After your testing, I suggest changing your password via http://loinc.org/forgot

It’s working! Thanks Tim! Really appreciate you helping out so quickly!

I’ve got what looks like the same problem. I get:
<div style=“color: #000000; background-color: #fffffe; font-family: Consolas, ‘Courier New’, monospace; font-size: 12px; line-height: 16px; white-space: pre;”>
<div><span style=“color: #383838;”><</span><span style=“color: #800000;”>html</span><span style=“color: #383838;”>></span></div>
 
<div><span style=“color: #383838;”><</span><span style=“color: #800000;”>head</span><span style=“color: #383838;”>></span></div>
<div> <span style=“color: #383838;”><</span><span style=“color: #800000;”>title</span><span style=“color: #383838;”>></span>HTTP 401 - Unauthorized<span style=“color: #383838;”></</span><span style=“color: #800000;”>title</span><span style=“color: #383838;”>></span></div>
<div> <span style=“color: #383838;”><</span><span style=“color: #800000;”>style</span> <span style=“color: #ff0000;”>type</span><span style=“color: #383838;”>=</span><span style=“color: #0000ff;”>“text/css”</span><span style=“color: #383838;”>></span></div>
<div> BODY {</div>
<div> font-family: Roboto, Arial;</div>
<div> }</div>
<div> <span style=“color: #383838;”></</span><span style=“color: #800000;”>style</span><span style=“color: #383838;”>></span></div>
<div><span style=“color: #383838;”></</span><span style=“color: #800000;”>head</span><span style=“color: #383838;”>></span></div>
 
<div><span style=“color: #383838;”><</span><span style=“color: #800000;”>body</span><span style=“color: #383838;”>></span></div>
<div> <span style=“color: #383838;”><</span><span style=“color: #800000;”>h1</span><span style=“color: #383838;”>></span>HTTP 401 - Unauthorized<span style=“color: #383838;”></</span><span style=“color: #800000;”>h1</span><span style=“color: #383838;”>></span></div>
<div> <span style=“color: #383838;”><</span><span style=“color: #800000;”>p</span><span style=“color: #383838;”>></span></div>
<div> Failure accessing /CodeSystem/$lookup</div>
<div> <span style=“color: #383838;”></</span><span style=“color: #800000;”>p</span><span style=“color: #383838;”>></span></div>
<div> <span style=“color: #383838;”><</span><span style=“color: #800000;”>p</span><span style=“color: #383838;”>></span></div>
<div> Problem: Unauthorized</div>
<div> <span style=“color: #383838;”></</span><span style=“color: #800000;”>p</span><span style=“color: #383838;”>></span></div>
<div> <span style=“color: #383838;”><</span><span style=“color: #800000;”>p</span><span style=“color: #383838;”>></span></div>
<div> Smile CDR v2020.02.PRE-29 (build c63ddb3650)<span style=“color: #383838;”><</span><span style=“color: #800000;”>br</span><span style=“color: #383838;”>/></span></div>
<div> <span style=“color: #383838;”></</span><span style=“color: #800000;”>p</span><span style=“color: #383838;”>></span></div>
<div><span style=“color: #383838;”></</span><span style=“color: #800000;”>body</span><span style=“color: #383838;”>></span></div>
 
<div><span style=“color: #383838;”></</span><span style=“color: #800000;”>html</span><span style=“color: #383838;”>></span></div>
</div>
<div></div>
<div>With curl, Postman, direct from browser, all the same. Changed my password, still the same.</div>

Looks like I didn’t paste the HTML response correctly. Anyway, the gist is:

HTTP 401 - Unauthorized

with curl, Postman, browser.

Hello Marc,

I apologize for the problem you are receiving. It seems the issue is with the password. Obviously it is working for you as you are able to log in to this site. Can you please reset/change your password to confirm? https://loinc.org/forgot/

Hi Tim,

Again no luck. Already changed my pwd, changed it again, now to a pwd containing only letters and digits. Still the 401. The new password works fine on the LOINC website itself.

I can send you my pwd (or maybe you can reset it?) if you mail me at marcdegraauw@gmail.com with an email that does not end in the Forums, so you can try yourself.

Regards,

Marc

Marc, thank you for your patience. I will follow up with you via email.

Hi,

I am experiencing the same issue, I am having trouble with the curl command, although I can log in fine via the website I get HTTP 401 - Unauthorized error when I try to connect via curl. I tried resetting the password as you suggested to the users before me but it didn’t help I get the same error (website login still fine)

curl -X GET -u dev@inrecovery.orghttps://fhir.loinc.org/CodeSystem/$lookup?system=http://loinc.org&amp;code=4544-3’ --header ‘Content-Type:application/fhir+json’

Could you tell me what was the solution for the users before me with the same issue?

Best regards,

Bogi

Hi Bogi, please be sure to use your LOINC username rather than email address as the identity. For instance, I use the following curl command with my username timbriscoe.

curl -X GET -u timbriscoe 'https://fhir.loinc.org/CodeSystem/$lookup?system=http://loinc.org&amp;code=4544-3&#039; --header 'Content-Type:application/fhir+json'

Dear Tim, thank you for the quick reply that worked like a charm.

Hi Tim,

I have tried the solution mentioned above but still get a 401. I suspect something might be wrong with my account settings. Could you please check it out?

 

This is my curl request:

curl -X GET -u danmbeyah ‘https://fhir.loinc.org/CodeSystem/$lookup?system=http://loinc.org&amp;code=4544-3’ --header ‘Content-Type:application/fhir+json’

Hi Tim,

Never mind, I got it to work. Thanks!

Hi Tim. How do I access the LOINC panels using python with my login credentials? I see from above it only requires username and not password? I am trying to download all panel templates. I am new to fhir

Hi Sivanersen,

You will want to use FHIR Questionnaire resource endpoint, i.e. https://fhir.loinc.org/Questionnaire. You can refer to https://loinc.org/fhir/#questionnaire for more information.

Tim

I had similar difficulty doing a simple little LOINC FHIR app in Java. The trick was to implement the generic “Basic Authentication” process in raw Java. I assume it is very similar in Python. I found https://stackoverflow.com/questions/6999565/python-https-get-with-basic-authentication that looks exactly the the way I did it with Java.

I apologize in advance if your question was really at the higher level.

Mike