PHPackages                             dcodegroup/laravel-xero-oauth - 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. dcodegroup/laravel-xero-oauth

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

dcodegroup/laravel-xero-oauth
=============================

Simple package which dcode uses to handle the connection to xero for all projects. Provides endpoints for UI and callbacks for Xero

1.0.24(2mo ago)129.4k↓42.9%3MITPHPPHP ^8.1CI passing

Since Sep 8Pushed 1y ago2 watchersCompare

[ Source](https://github.com/DCODE-GROUP/laravel-xero-oauth)[ Packagist](https://packagist.org/packages/dcodegroup/laravel-xero-oauth)[ RSS](/packages/dcodegroup-laravel-xero-oauth/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (27)Used By (3)

[![Latest Version](https://camo.githubusercontent.com/809966dcf103cf9faeb5a13e3980a10ce0f9fc57d1d397bf24e129f488909a8d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f64636f646567726f75702f6c61726176656c2d7865726f2d6f617574682e7376673f7374796c653d666c61742d737175617265)](https://github.com/dcodegroup/laravel-xero-oauth/releases)[![GitHub Workflow Status](https://camo.githubusercontent.com/88cf6ed8b4871b553042868c7b08688242240346e8d69f1b57479df6e3bcfb3c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f64636f646567726f75702f6c61726176656c2d7865726f2d6f617574682f436865636b253230262532306669782532307374796c696e67)](https://camo.githubusercontent.com/88cf6ed8b4871b553042868c7b08688242240346e8d69f1b57479df6e3bcfb3c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f64636f646567726f75702f6c61726176656c2d7865726f2d6f617574682f436865636b253230262532306669782532307374796c696e67)[![Total Downloads](https://camo.githubusercontent.com/6d9125dd47e8679141026e559da8561daab441f6648b6f6170a2d00498fe630e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64636f646567726f75702f6c61726176656c2d7865726f2d6f617574682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dcodegroup/laravel-xero-oauth)

Laravel Xero
============

[](#laravel-xero)

This package provides the standard xero connection functionality used in most projects.

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

[](#installation)

You can install the package via composer:

```
composer require dcodegroup/laravel-xero-oauth
```

Then run the install command.

```
php artsian laravel-xero:install
```

This will publish the configuration file and the migration file.

Run the migrations

```
php artsian migrate
```

Configuration
-------------

[](#configuration)

Most of configuration has been set the fair defaults. However you can review the configuration file at `config/laravel-xero-oauth.php` and adjust as needed

If you want to have the oauth screens appear within your sites layout ensure to configure the environment variable. eg.

`LARAVEL_XERO_OAUTH_APP_LAYOUT=layouts.admin`

Usage
-----

[](#usage)

The package provides an endpoints which you can use. See the full list by running

```
php artsian route:list --name=xero
```

```
+--------+----------+-------------------------+--------------------+-------------------------------------------------------------------------+----------------------------------+
| Domain | Method   | URI                     | Name               | Action                                                                  | Middleware                       |
+--------+----------+-------------------------+--------------------+-------------------------------------------------------------------------+----------------------------------+
|        | GET|HEAD | xero                    | xero.index         | Dcodegroup\LaravelXeroOauth\Http\Controllers\XeroController             | web                              |
|        |          |                         |                    |                                                                         | App\Http\Middleware\Authenticate |
|        | GET|HEAD | xero/auth               | xero.auth          | Dcodegroup\LaravelXeroOauth\Http\Controllers\XeroAuthController         | web                              |
|        |          |                         |                    |                                                                         | App\Http\Middleware\Authenticate |
|        | GET|HEAD | xero/callback           | xero.callback      | Dcodegroup\LaravelXeroOauth\Http\Controllers\XeroCallbackController     | web                              |
|        |          |                         |                    |                                                                         | App\Http\Middleware\Authenticate |
|        | POST     | xero/tenants/{tenantId} | xero.tenant.update | Dcodegroup\LaravelXeroOauth\Http\Controllers\SwitchXeroTenantController | web                              |
|        |          |                         |                    |                                                                         | App\Http\Middleware\Authenticate |
+--------+----------+-------------------------+--------------------+-------------------------------------------------------------------------+----------------------------------+

```

More Information

`example.com/xero` Which is where you will generate the link to authorise xero. This is by default protected auth middleware but you can modify in the configuration. This is where you want to link to in your admin and possibly a new window

`example.com/xero/callback` This is the route for which xero will redirect back to after the oauth has occurred. This is excluded from the middleware auth. You can change this list in the configuration also.

BaseXeroService
---------------

[](#basexeroservice)

The package has a `BaseXeroService` class located at `Dcodegroup\LaravelXeroOauth\BaseXeroService`

So your application should have its own XeroService extend this base class as the initialisation is already done.

```
