Example Google Script to handle authentication and PUT to Xero.com's API
After quite a bit of research and piecing together a few resources I managed to create a simple 'just works' solution for connecting Google Apps Script (in my case from Sheets) to Xero.com's API.
If you've found yourself here, I hope this saves you some time 😇
To get the code to work you need to input your CONSUMER_KEY
and PEM_KEY
where noted.
Note: I just needed a quick and dirty solution for this, I know the code can be vastly improved, if you have time feel free to submit a pull request.
Is a pretty straightforward read, you need to change:
- Required API
URL
payload
(in accordance with Xero's API docs)
And it should 'just work'
Version 5.0.1
is specifically used as it doesn't use as many external dependencies as the newer versions.
Is used to read the PEM key from string then sign it to send through the oauth process