OAuth 1.1 with Xero

Introduction

Xero is a cloud based accounting program. The API for Xero makes use of OAuth 1.1 for authentication using RSA-SHA based signing.

This example channel shows how you can connect Iguana to this API. It makes use of the crypto APIs which are available in Iguana 6.0.2 and up.

For more information on Oauth 1.1 and connecting to Xero, this earlier article on the topic may be useful.

If you have any questions please contact us at support@interfaceware.com.

Tip: The code for this channel uses stores the the Xero login information (key, secret) in plain text this is not best practice.

You can use the encrypt.password.lua and store2.lua modules to store logon information in encrypted format, see the Salesforce.com Adapter for an example of how to do this.

Setup Xero [top]

  1. Go to xero.com and register a free account
  2. Login and click the “Try Demo Company” link at the bottom of the “Setup Organization” page
  3. In another tab go to https://api.xero.com
  4. Click the “My Applications” tab
  5. Select the “Private – just for use with my own organization” radio button
  6. Give the application a name such as “Iguana”
  7. Leave “Demo Company” selected
  8. Create an RSA Public/Private key pair. See https://developer.xero.com/documentation/auth-and-limits/private-applications. Follow the documentation from:
  9. Upload the X509 public certificate you created in the Creating the RSA Public/Private Keys section
  10. Upload the private.pem into the “other” folder of the demo channel
    1. Click the plus [+] next other in the project panel:
    2. Choose the Upload a File tab and Browse to find your private.pem file, then click Add File:
  11. Click the submit button to create the application
  12. You now have the required values to call the Xero APIs from Iguana. Copy over the consumer key and the consumer secret
  13. The script should now be able to connect to Xero and give you a list of Xero users for the Xero instance you have connected to

Using the Code [top]

  • Import the OAuth 1.1 with Xero channel from the Builtin: Iguana Webservices repository
  • Experiment with the code to find out how it works
  • Then add the modules to your Translator project
  • Copy the require statement from the channel and add it at the top of your script
    Note: The twitter.api.lua module uses require to return a table
    Note: The oauth.oauth.lua module uses require to return a table
  • Adapt the code to your own requirements
  • Interactive scripting help is included for this module

This is the github code for the main module:

How it works [top]

The API for Xero makes use of OAuth 1.1 for authentication using RSA-SHA based signing.

This example channel shows how you can connect Iguana to this API.  It makes use of the crypto APIs which are available in Iguana 6.0.2 and up.

More information [top]

Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.