What’s on this page?
- 3 legged OAuth
- 30 minute access tokens
- Connecting to Xero
- Technical details
- How to register an application
- URLs for authorisation and using the API
- Signing requests
Public applications use the standard 3 legged OAuth process where a user can authorise your application to have access to their Xero organisation.
Public applications can either be web based or desktop/mobile installed. Access tokens expire after 30 minutes.
Connecting to Xero
Below is a summary of the steps required for an end user to authorise a public application to have access to their organisation in Xero
- User presses a “Connect to Xero” button or something similar in the 3rd party application.
- User is redirected to Xero and prompted to login if they do not already have an active session.
- User is requested to select which Xero organisation they want to grant the application access to.
- Once the application is authorised, the user is redirected back to the 3rd party application, which can then start interacting with their Xero organisation using the Xero API for up to 30 minutes
How to register an application
Any Xero user can register a public application. If you do not already have a Xero user account, sign up for a free account.
- Login to the Xero Developer portal
- Go to the My Applications > Add Application screen to add your application.
- Select “Public” and enter a name for your application and the URL of your company
- Optionally you can enter a callback domain. This will be used to verify the callback url you specify when authorising is allowed.
- Choose save. You’ll now be shown your OAuth credentials.
URLs for authorisation and using the API
Xero follows the OAuth v1.0a spec. The URL’s to authorize your application are:
|Get an Unauthorised Request Token:||https://api.xero.com/oauth/RequestToken|
|Redirect a user:||https://api.xero.com/oauth/Authorize|
|Swap a Request Token for an Access Token:||https://api.xero.com/oauth/AccessToken|
|Connect to the Xero API:||https://api.xero.com/api.xro/2.0/…|
- When getting a request token and specifying the callback URL, the callback URL should be no more than 250 characters long.
- The callback url must be within the domain specified when registering your app. Learn more
- If a callback url is not specified then the user will be given an authorisation code to enter into your application.
All requests need to be signed using HMAC-SHA1.
- Each access token will only last for 30 minutes.
- If you want longer access to the organisation, you will need the user to re-authorize your application.
There are many wrapper libraries available for the Xero API that have built in support for OAuth 1.0a. We highly recommend you use one of these to get up and running.