An Insomnia collection for authenticating to and calling many of the Xero API endpoints.
Follow these steps to quickly get up and running with the Xero API and Insomnia.
Visit Insomnia and download the desktop client.
In the Xero developer portal create an API app.
Set 'OAuth 2.0 redirect uri' to: "https://localhost/"
If you haven't signed up for a xero developer account you can do that here.
This collections has a single authentication route and one sample API call
This collection has the majority of the XeroAPI endpoints already built out
Get the id & secret from your /myapps API app.
Understand & pick your XeroAPI scopes.
At a minimun you probably want to add
"openid profile email offline_access accounting.transactions"
- and if you chose the Full Collection you will have to add (basically) all the scope to interact with all the imported endpoints.
Finally, copy those 3 items into this file in your desktop client.
Click 'Fetch Tokens' which will prompt a Xero login screen.
Once you return it should populate the access & refresh token.
You can now add an actual request to the Authorize OAuth2 panel to hit the /connections route via POST which will use the access_token to return your active connections.
Once the /connection route is setup, click Send
, this will return your active API connections. Chose a tenantId
to populate in your environment file's empty tenant_id
value.
Then paste both the tenant_id
& the access_token
into the environment file.
Once you have an access_token
plugged in, you will be able to make API calls.
You can continually visit the Authentication
route to refresh a token by clicking Refresh Token
.
IMPORTANT
You will need to copy/paste your refreshed access_token
into the env variables section each time you refresh your token_set.
~13 min video tutorial on setting up Insomnia
Blogpost on setting up Insomnia
https://devblog.xero.com/insomnia-client-xeroapi-auth-1c4cf485f251