Page 1 of 1

Oauth2

Posted: Mon May 25, 2020 6:55 pm
by eworthington
Hello,

I have been trying to work with the Oauth library, but I cannot seem to resolve an issue.

As a test, I am trying to use the Epic (uscdi.epic.com) EMR API (which uses Oauth2 for authentication). I created a sample stack with a single button. On the button, I added the following code.

Code: Select all

on mouseUp
   
   constant tAuthURL = "https://uscdi.epic.com/interconnect-uscdi-oauth/oauth2/authorize?response_type=code"
   constant tToken = "https://uscdi.epic.com/test/smart"
   constant tPort = 49152
   
   
   put "KEY HERE" into clientKey["Test"]
   put "KEY HERE" into clientKey["Production"]
   
   
   --https://uscdi.epic.com/interconnect-uscdi-oauth/oauth2/authorize?response_type=code&redirect_uri=[redirect_uri]&client_id=[client_id]&state=[state]
   
   -- OAuth2 pAuthURL,pTokenURL,pClientID,pClientSecret,pScopes,pPort,pParams
   OAuth2 tAuthURL,'pToken', clientKey["Test"], , , tPort
   
   if the result is not empty then
      put the result & " " & it
   end if
   
end mouseUp
I keep getting an Oauth Error from Epic. The error is in the authentication window that opens. The result or it internal variables in LiveCode only return 'cancel' as I have to click on the cancel button to close the authentication popup. When I register it only provides a clientID for test and production, and I am using localhost:49152 (http and https as it allows both) for the redirect.

The documentation is behind a password wall but registration is free.

To make it easier, I have attached it to this post. The section starts under "Standalone Launch."

The error I get is

"OAuth2 Error
Something went wrong trying to authorize the client. Please try logging in again.

© 2003-2019 Epic Systems Corporation"

Thank you for any advice.

Ed

Re: Oauth2

Posted: Tue May 26, 2020 8:55 am
by MichaelBluejay
I'm very sorry to ask this, but you did replace "KEY HERE" with the actual key, right?

Also, some of your fields are empty, are you sure you don't have to pass all the fields in your call?

Re: Oauth2

Posted: Fri Jun 05, 2020 5:56 am
by eworthington
Thank you.

Yes, I replaced it with the key. I used all of the values in the API call that I could find in the documentation from Epic.