PHPackages                             derrickleemy/laravel-xero-oauth2 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. derrickleemy/laravel-xero-oauth2

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

derrickleemy/laravel-xero-oauth2
================================

A Laravel integration for Xero using the Oauth 2.0 spec

v1.1.2(6y ago)0359MITPHPPHP ^7.3

Since Jan 26Pushed 6y agoCompare

[ Source](https://github.com/derrickleemy/laravel-xero-oauth2)[ Packagist](https://packagist.org/packages/derrickleemy/laravel-xero-oauth2)[ Docs](https://github.com/webfox/laravel-xero-oauth2)[ RSS](/packages/derrickleemy-laravel-xero-oauth2/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (4)Versions (5)Used By (0)

A Laravel integration for Xero using the Oauth 2.0 spec
=======================================================

[](#a-laravel-integration-for-xero-using-the-oauth-20-spec)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8e7957797a6b3be38f0d40648949ec2154b54d679574d511373117aa40a5c14d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776562666f782f6c61726176656c2d7865726f2d6f61757468322e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/webfox/laravel-xero-oauth2)[![Total Downloads](https://camo.githubusercontent.com/7adc4296684064baf960ed169d892ccc1ab073f975468019139002842e476b95/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f776562666f782f6c61726176656c2d7865726f2d6f61757468322e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/webfox/laravel-xero-oauth2)

This package integrates the new reccomended package of [xeroapi/xero-php-oauth2](https://github.com/XeroAPI/xero-php-oauth2) using the Oauth 2.0 spec with Laravel.

Installation
------------

[](#installation)

You can install this package via composer using the following command:

```
composer require webfox/laravel-xero-oauth2

```

The package will automatically register itself.

You can publish the configuration file with:

```
php artisan vendor:publish --provider="Webfox\Xero\XeroServiceProvider" --tag="config"

```

You'll want to set the scopes required for your application in the config file.

You should add your Xero keys to your .env file using the following keys:

```
XERO_CLIENT_ID=
XERO_CLIENT_SECRET=

```

When setting up the application in Xero ensure your redirect url is https://{your-domain}/xero/auth/callback

Using the Package
-----------------

[](#using-the-package)

This package registers two bindings into the service container you'll be interested in:

- `\XeroAPI\XeroPHP\Api\AccountingApi::class` this is the main api for Xero - see the [xeroapi/xero-php-oauth2 docs](https://github.com/XeroAPI/xero-php-oauth2/tree/master/docs) for usage. When you first resolve this dependency if the stored credentials are expired it will automatically refresh the token.
- `Webfox\Xero\OauthCredentialManager` this is the credential manager - The Accounting API requires we pass through a tenant ID on each request, this class is how you'd access that. This is also where we can get information about the authenticating user. See below for an example.

*app\\Http\\Controllers\\XeroController.php*

```
