All Xero APIs require apps to operate on behalf of a user. Connecting your app to a Xero account requires a user to grant consent in a web browser. This can be challenging if you’re building a back-end integration that doesn’t have a user interface.
For integrations like these, our CLI tool XOAuth allows you to establish an offline connection with a Xero user’s account directly from the command line. No web development required.
To get started, simply download the binary for your platform (Linux, Mac OS or Windows) from the Github repo. Once you have XOAuth installed, you run one command to setup your client and a second to make the connection.
The connection command will automatically open a web browser for the Xero user to log in and consent to your app. Once the user has given consent, all the tokens will be displayed in the web browser as well as being piped to stdout so you can use them in a script workflow.
Check the README for detailed instructions on how to use XOAuth.
Xero’s access tokens have a limited lifespan of 30 minutes but they can be refreshed using a refresh token. This means your integration can maintain an offline connection without needing the user to re consent to your app.
To keep the connection alive there are just a couple of points to keep in mind:
If you follow these steps it should be pretty straightforward to get you machine to machine style integration up and running and for it to run seamlessly in the background without user interaction.