Page 1 of 1
LiveCode + Xero (OAuth1.0a)
Posted: Tue Jul 11, 2017 1:58 pm
by aphero
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
Re: LiveCode + Xero (OAuth1.0a)
Posted: Sun Jul 30, 2017 12:47 am
by lilRalph
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.
Re: LiveCode + Xero (OAuth1.0a)
Posted: Tue Aug 01, 2017 2:43 pm
by MaxV
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
Re: LiveCode + Xero (OAuth1.0a)
Posted: Thu Aug 24, 2017 12:43 pm
by aphero
@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
Re: LiveCode + Xero (OAuth1.0a)
Posted: Thu Aug 24, 2017 3:52 pm
by MaxV
The last version of free livecode has the OAUTH2 libraries:
Can you use them?
Re: LiveCode + Xero (OAuth1.0a)
Posted: Fri Aug 25, 2017 3:15 am
by aphero
@ 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
Re: LiveCode + Xero (OAuth1.0a)
Posted: Sun Jul 19, 2020 7:08 pm
by aetaylorBUSBnWt
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
Re: LiveCode + Xero (OAuth1.0a)
Posted: Sun Jul 26, 2020 1:49 pm
by JackieBlue1970
I’m curious, have you tried the solution noted above using the POST and GET functions?
Re: LiveCode + Xero (OAuth1.0a)
Posted: Wed Jul 29, 2020 2:30 am
by aetaylorBUSBnWt
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.
Re: LiveCode + Xero (OAuth1.0a)
Posted: Wed Jul 29, 2020 8:45 am
by bn
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
Re: LiveCode + Xero (OAuth1.0a)
Posted: Wed Jul 29, 2020 5:23 pm
by aetaylorBUSBnWt
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
Re: LiveCode + Xero (OAuth1.0a)
Posted: Thu Feb 11, 2021 7:27 pm
by aetaylorBUSBnWt
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