1

I have a client that wants to be able to create xero invoices from a custom backend plugin that I have created in WordPress. I understand the xero api docs and what data to pass to the api to create a new invoice but I have to somehow authenticate the user so that they can send data to the api. So far I have created my xero app with a client id and client secret which I believe is required to help authenticate the api request.

But how can I authenticate the api request?

If I do simple request like this it fails:

jQuery(document).ready(function ($) {
    $.ajax({
        url: 'https://api.xero.com/connections',
        error = (res) => {
            console.log(res);
        },
        success = (res) => {
            console.log(res);
        }
    });
});
Reece
  • 2,581
  • 10
  • 42
  • 90

1 Answers1

1

I'd first recommend using the official xero PHP sdk, however I'm not sure if you are able to import packages to Wordpress like this. I've done some wordpress but I know there are some limitations with importing certain external libraries.

https://github.com/XeroAPI/xero-php-oauth2

However as an alternate solution, theres a recent blogpost on using a raw OAuth2.0 library to connect to XeroAPI manually though. This might set you on the right direction!

https://medium.com/@sid.maestre/use-php-to-connect-with-xero-31945bccd037

SerKnight
  • 2,502
  • 1
  • 16
  • 18
  • 1
    I did find the xero php library but as you said I don't think its possible to include this library in WordPress. I'll look into that other solution though. Thanks! – Reece Aug 14 '20 at 10:16