PHPackages                             ursuleacv/oauth2-lightspeed - 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. ursuleacv/oauth2-lightspeed

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

ursuleacv/oauth2-lightspeed
===========================

LightSpeed OAuth 2.0 Client Provider for The PHP League OAuth2-Client

v3.0.0(1y ago)61.2k3MITPHPPHP &gt;=8.1.0

Since Mar 16Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ursuleacv/oauth2-lightspeed)[ Packagist](https://packagist.org/packages/ursuleacv/oauth2-lightspeed)[ RSS](/packages/ursuleacv-oauth2-lightspeed/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (6)Versions (34)Used By (0)

LightSpeed Provider for OAuth 2.0 Client
========================================

[](#lightspeed-provider-for-oauth-20-client)

[![Build Status](https://camo.githubusercontent.com/aa13895215142b40260e62e958ff4cb77b62419ba09e23aeaba61fc2934a6e6a/68747470733a2f2f7472617669732d63692e6f72672f757273756c656163762f6f61757468322d6c6967687473706565642e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/ursuleacv/oauth2-lightspeed)

This package provides LightSpeed OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

This package is compliant with [PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md), [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md), [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md), and [PSR-7](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-7-http-message.md). If you notice compliance oversights, please send a patch via pull request.

Requirements
------------

[](#requirements)

The following versions of PHP are supported.

- PHP 8.1
- PHP 8.2
- PHP 8.3
- PHP 8.4
- HHVM

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

[](#installation)

Add the following to your `composer.json` file.

```
{
    "require": {
        "ursuleacv/oauth2-lightspeed": "~3.0"
    }
}
```

Usage
-----

[](#usage)

### Authorization Code Flow

[](#authorization-code-flow)

```
session_start();

$provider = new League\OAuth2\Client\Provider\Lightspeed([
    'clientId'                => LIGHTSPEED_CLIENT_ID,
    'clientSecret'            => LIGHTSPEED_CLIENT_SECRET,
    'redirectUri'             => LIGHTSPEED_REDIRECT_URI,
]);

if (!isset($_GET['code'])) {

    // If we don't have an authorization code then get one
    $authUrl = $provider->getAuthorizationUrl([
        'scope' => ['employee:all', '...', '...'],
    ]);
    $_SESSION['oauth2state'] = $provider->getState();

    echo 'Log in with LightSpeed!';
    exit;

// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {

    unset($_SESSION['oauth2state']);
    echo 'Invalid state.';
    exit;

}

// Try to get an access token (using the authorization code grant)
$token = $provider->getAccessToken('authorization_code', [
    'code' => $_GET['code']
]);

try {

    // We got an access token, let's now get the Account ID and sale details
    $client = $provider->getResourceOwner($token);
    $merchantos = $provider->merchantosApi($token, $client->getId());

    $clientId = $client->getId();
    $sale = $merchantos->getSale(1);

    echo '';
    print_r($client); echo '';
    print_r($sale); echo '';
    echo '';

} catch (Exception $e) {
    exit($e->getMessage());
}

echo '';
// Use this to interact with an API on the client behalf
var_dump($token->getToken());

echo '';
```

Testing
-------

[](#testing)

```
$ ./vendor/bin/phpunit
```

Upgrading
---------

[](#upgrading)

```
vendor/bin/rector process src --dry-run
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/ursuleacv/oauth2-lightspeed/blob/master/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Valentin Ursuleac](https://github.com/ursuleacv)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/ursuleacv/oauth2-lightspeed/blob/master/LICENSE) for more information.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 84% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~99 days

Recently: every ~483 days

Total

33

Last Release

523d ago

Major Versions

1.0.2 → 2.0.02016-03-31

v2.1.2 → v3.0.02024-12-05

PHP version history (3 changes)1.0.0PHP &gt;=5.5.0

2.0.29PHP &gt;=5.6.0

v3.0.0PHP &gt;=8.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/424d9ca5591c38124f956f99d581e919491044485279074fd69a08a0934cee51?d=identicon)[ursuleacv](/maintainers/ursuleacv)

---

Top Contributors

[![ursuleacv](https://avatars.githubusercontent.com/u/1458222?v=4)](https://github.com/ursuleacv "ursuleacv (63 commits)")[![kangaroo-val](https://avatars.githubusercontent.com/u/22823136?v=4)](https://github.com/kangaroo-val "kangaroo-val (10 commits)")[![vambus](https://avatars.githubusercontent.com/u/2419721?v=4)](https://github.com/vambus "vambus (2 commits)")

---

Tags

lightspeedoauth-clientoauth2phpclientAuthenticationoauthoauth2authorizationlightspeed

###  Code Quality

TestsPHPUnit

Static AnalysisRector

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/ursuleacv-oauth2-lightspeed/health.svg)

```
[![Health](https://phpackages.com/badges/ursuleacv-oauth2-lightspeed/health.svg)](https://phpackages.com/packages/ursuleacv-oauth2-lightspeed)
```

###  Alternatives

[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[cakedc/oauth2-cognito

Cognito OAuth 2.0 Client Provider for The PHP League OAuth2-Client

18597.7k](/packages/cakedc-oauth2-cognito)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
