Written by

Enterprise Application Development Consultant at The Ohio State University Wexner Medical Center
MOD
Question Scott Roth · Nov 17, 2023

Testing OAuth2

Go to the original post@Scott Roth

I am attempting to setup my first OAuth2 client, as we are adventuring into the realm of making FHIR API calls to our EMR from HealthShare Health Connect. 

I have gone through and set up the Issuer Endpoint, and Client Configuration but now I want to test it and verify that the setup is correct. When I setup the Client Configuration, it would not allow me to use Discovery as it was saying I needed a "Client secret" but was not given one. So I set it up manually, thinking I hit all the information correctly.

However, if I go through the documentation and use GetAuthorizationCodeEndpoint, I am receiving an error saying the AccessTokenID is required. Did I miss a step in trying to test the connection? 

%SYS>set url = ##class(%SYS.OAuth2.Authorization).GetAuthorizationCodeEndpoint(OAUTHCLIENT,"scope1",OAUTHURL,.properties,.isAuthorized,.sc)

%SYS>zwrite sc
sc="0 "_$lb($lb(5659,"OAuth2.AccessToken::SessionId(6@OAuth2.AccessToken,ID=)",,,,,,,,$lb("%ValidateObject+24^OAuth2.AccessToken.1","%SYS",$lb("e^%ValidateObject+24^OAuth2.AccessToken.1^3","e^%SerializeObject+3^OAuth2.AccessToken.1^1","e^%Save+8^OAuth2.AccessToken.1^5","e^GetRequestEndpoint+139^%SYS.OAuth2.Authorization.1^1","e^GetAuthorizationCodeEndpoint+1^%SYS.OAuth2.Authorization.1^1","e^^^0"))))/* ERROR #5659: Property 'OAuth2.AccessToken::SessionId(6@OAuth2.AccessToken,ID=)' required */

Does anyone have the proper sequence written out that I can use to test the OAuth from Terminal so I can continue on my quest to access the EMR FHIR repository?

Product version: IRIS 2023.1
$ZV: IRIS for UNIX (Red Hat Enterprise Linux 8 for x86-64) 2023.1.2 (Build 450U) Mon Oct 16 2023 10:40:47 EDT

Comments

Scott Roth · Nov 17, 2023

I was able to get past the ERROR #5659: Property 'OAuth2.AccessToken::SessionId(6@OAuth2.AccessToken,ID=)' required by specifying an ID at the end of the request...

%SYS>set url = ##class(%SYS.OAuth2.Authorization).GetAuthorizationCodeEndpoint("EpicFHIRPOC",scope,OAUTHURL,.properties,.isAuthorized,.sc,,123)

so the sc returns 1, however isAuthorized is still returning 0. If I run IsAuthorized, I am not seeing any errors.

Am I taking the correct steps? How do I get the Token?

0
Amy Lin  Dec 4, 2023 to Scott Roth

GetAuthorizationCodeEndpoint() needs to be called from a valid %session. One way to do this is extend from %OAuth2.Login. 

0