Skip to content

catchshyam/xero-api-public-application-nodejs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Xero PUBLIC application using API client implemented in node.js

A Xero PUBLIC application obtains a 30 minute access token using three-legged oAuth1.0.

This sample application uses the standard oauth npm to authenticate with Xero and access the API endpoints.

Three-legged oAuth 1.0 requires that the application (the oAuth consumer) provides endpoints (views) for the user to initiate the authentication and redirect to and from Xero. For this example I've used hapi.js, but if you express or koa there's only subtle differences with the request and response arguments.

Flow diagram of three-legged oAuth with Xero API

There's a lot of comments in the code, but for an explanation see my blog.

Getting started

  1. Clone the repo

  2. Install the packages

    npm init

  3. Run it (the defaults are localhost on port 8001)

    node src/server.js

  4. Browse to http://localhost:8001/ and authenticate with Xero.

Configuration

Here's what you'll want to change if you copy the code:

  1. Your consumer token and secret generated by Xero
  2. The two end-point URLs
  3. The callback URL
  4. For the endpoint's you need to access, create functions that invoke the endpoint via the oauth module (eg. oauth.get()) and work with the Resposne object.

About

An example PUBLIC application using the Xero API implemented in node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 97.4%
  • HTML 2.6%