LiveCode + Xero (OAuth1.0a)

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
aphero
Posts: 6
Joined: Tue Jul 11, 2017 1:43 pm
Location: Sydney, Australia

LiveCode + Xero (OAuth1.0a)

Post by aphero » Tue Jul 11, 2017 1:58 pm

Hi All,

I am trying to integrate Xero (cloud-based accounting platform) with LiveCode and I'm not having fun.

Xero uses OAuth1.0a, I notice LiveCode has a library for OAuth2.0.

Has anyone done OAuth1.0a integration before? Help!

Thanks,
DK

lilRalph
Posts: 23
Joined: Wed Aug 26, 2015 9:43 am

Re: LiveCode + Xero (OAuth1.0a)

Post by lilRalph » Sun Jul 30, 2017 12:47 am

G'Day Aphero,

No I haven't but I do have an appllication which logs into a site (mine) with https and uses public & private keys for encryption.

Doing a bit of quick reading about the difference between OAuth1.0 & 2.0 seems they are not compatible and the library will not be much help right now.
However, LiveCode already has https and encryption/decryption capabilities built in and they are easy to implement.

Logging into the site can be done with the Javascript handlers so that you can use the token provided by the Xero site for your authentication, much easier than trying to build a POST request from data stripped from the site and looks more like an end user to the site. I have a couple of posts here on how to do that if you need help.

Using Javascript you can maipulate cookies at any time on any page unlike PHP so you can get access to the session cookie if you need to, but you shouldn't need that if you are doing all your website stuff through the browser widget.

Moving your program data between your code and the browser widget is a bit tricky but not difficult, again I have posts here with the info you need.

Good Luck.

MaxV
Posts: 1342
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: LiveCode + Xero (OAuth1.0a)

Post by MaxV » Tue Aug 01, 2017 2:43 pm

Just use put, post and get.
For example:
A Request token:

Code: Select all

put URL "http://term.ie/oauth/example/request_token.php?oauth_version=1.0&oauth_nonce=9b5e850e1d7d5662186274d01c44f828&oauth_timestamp=1501581721&oauth_consumer_key=key&oauth_signature_method=HMAC-SHA1&oauth_signature=mkgDlwnAie3ZtiIqmuiIzQu82qQ%3D"
You get:

Code: Select all

oauth_token=requestkey&oauth_token_secret=requestsecret
The Request Token provided above is already authorized, you may use it to request an Access Token right away.

Code: Select all

  put "oauth_signature=secret%2526requestsecret" after myData
   put "&oauth_token=requestkey"  after myData
   put "&oauth_token_secret=requestsecret" after myData
   put "&oauth_consumer_key=key" after  myData
   put "&oauth_timestamp=" & the seconds  after myData   
   put "&oauth_signature_method=PLAINTEXT" after myData       
   post myData to URL "http://term.ie/oauth/example/access_token.php"
   put it 
You get

Code: Select all

oauth_token=accesskey&oauth_token_secret=accesssecret
:D
Livecode Wiki: http://livecode.wikia.com
My blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w

aphero
Posts: 6
Joined: Tue Jul 11, 2017 1:43 pm
Location: Sydney, Australia

Re: LiveCode + Xero (OAuth1.0a)

Post by aphero » Thu Aug 24, 2017 12:43 pm

@MaxV

> Just use put, post and get.

This is what I am trying to achieve.

Xero uses Auth1.0a, and I think it is a one-legged approach, I'm using a private application, link below.

h_t_t_p_s://developer[.]xero[.]com/documentation/auth-and-limits/private-applications

Q1 - Where did you get the oauth_nonce from?
Q2 - Where did you get the oauth_signature from?

I have tried to use your code however it doesn't work for me, I have begun constructing the first put such as.

Code: Select all

on mouseUp
  
   // Credentials are for a test account
   put "WT9MWX8A3SOQTM5MY8I86ORDYORM22" into ConsumerKey
   put "HSR8VU8ZUSAUZP8Y29F54NL4GIT2NV" into ConsumerSecret
   put "h_t_t_p_s://api[.]xero[.]com/api.xro/2.0/" into URI_1
   put "" into URI_2
   put "" into URI_3
   put URI_1 & URI_2 into PostURI
 
  //Put
   put URL PostURI
   
answer "Check"
end mouseUp
Any help is greatly appreciated.

Thanks,
DK

MaxV
Posts: 1342
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: LiveCode + Xero (OAuth1.0a)

Post by MaxV » Thu Aug 24, 2017 3:52 pm

The last version of free livecode has the OAUTH2 libraries: Can you use them?
Livecode Wiki: http://livecode.wikia.com
My blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w

aphero
Posts: 6
Joined: Tue Jul 11, 2017 1:43 pm
Location: Sydney, Australia

Re: LiveCode + Xero (OAuth1.0a)

Post by aphero » Fri Aug 25, 2017 3:15 am

@ MaxV

No, Xero uses OAuth1.0a only, and I don't believe they are looking at changing anytime soon, I will raise it with them though.

Thanks,
DK

Post Reply

Return to “Internet”