Oauth2

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
eworthington
Posts: 9
Joined: Tue May 14, 2019 5:12 am

Oauth2

Post by eworthington » Mon May 25, 2020 6:55 pm

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
Attachments
epic_uscdi_oauth.zip
(190.97 KiB) Downloaded 162 times

MichaelBluejay
Posts: 222
Joined: Thu Jul 01, 2010 11:50 am

Re: Oauth2

Post by MichaelBluejay » Tue May 26, 2020 8:55 am

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?

eworthington
Posts: 9
Joined: Tue May 14, 2019 5:12 am

Re: Oauth2

Post by eworthington » Fri Jun 05, 2020 5:56 am

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.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”