LiveCode + Xero (OAuth1.0a)

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

Moderators: FourthWorld, heatherlaine, Klaus, 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: 25
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: 1579
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: https://livecode-blogger.blogspot.com
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: 1579
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: https://livecode-blogger.blogspot.com
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

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

Re: LiveCode + Xero (OAuth1.0a)

Post by aetaylorBUSBnWt » Sun Jul 19, 2020 7:08 pm

Hello,

It has been 3 years since this thread had any activity.

I also have a vendor running OAuth1.0a, and the vendor has no intention of upgrading.
I have an API and some example code in JAVA. The vendor does not supply any other means of accessing their web site.

Is there any direct support in LiveCode for OAuth1.0a since there are vendors who don't believe that they need anything better than that?

Or do I need to figure out how to create and import a Java library and call it?

If so, is there a tutorial for doing this?

Thanks,
Andrew

JackieBlue1970
Posts: 64
Joined: Thu Jan 16, 2020 10:28 pm
Location: Max Meadows, VA USA

Re: LiveCode + Xero (OAuth1.0a)

Post by JackieBlue1970 » Sun Jul 26, 2020 1:49 pm

I’m curious, have you tried the solution noted above using the POST and GET functions?

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

Re: LiveCode + Xero (OAuth1.0a)

Post by aetaylorBUSBnWt » Wed Jul 29, 2020 2:30 am

Hello,

On another thread I found a post with a link to code to generate the HMACSHA1 oauthSignature from (can't find the link), anyway, from a while ago.
After I fixed a bunch bugs due to no local variables being declared, it works.

So that is the most difficult part of getting oauth1.0a going, since it involves lots of fancy hashing in a special way.

Next to find some oauth_nonce code somewhere.

Has anybody generated any code for that?

Once I stitch all the pieces together for oauth1.0a I will be asking how to put that stack into something publicly available to the rest of you.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3975
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: LiveCode + Xero (OAuth1.0a)

Post by bn » Wed Jul 29, 2020 8:45 am

aetaylorBUSBnWt wrote:
Wed Jul 29, 2020 2:30 am

On another thread I found a post with a link to code to generate the HMACSHA1 oauthSignature from (can't find the link), anyway, from a while ago.
the link seems to be

viewtopic.php?f=11&t=22957&p=118539&hil ... A1#p118539

Kind regards
Bernd

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

Re: LiveCode + Xero (OAuth1.0a)

Post by aetaylorBUSBnWt » Wed Jul 29, 2020 5:23 pm

Excellent, thanks for that reference.

I added his name (Mark Smith) to the library code I downloaded and the web link - he had not given himself credit.

That wasn't the link I found the code from - that link took me to his web site that has several of his libraries available for download.

The link is: http://marksmith.on-rev.com/revstuff/

thanks,
Andrew

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

Re: LiveCode + Xero (OAuth1.0a)

Post by aetaylorBUSBnWt » Thu Feb 11, 2021 7:27 pm

Hi,

I got nonce calculated, got the HMAC-SHA1 stuff working in Livecode.

Now - Java RestTemplate code is the stumbling block.

Is there a RestTemplate library for Livecode anywhere?

Thanks,
Andrew

Post Reply

Return to “Internet”