2017 © Pedro Peláez
 

library oauth2-lightspeed

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

image

ursuleacv/oauth2-lightspeed

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

  • Tuesday, May 8, 2018
  • by ursuleacv
  • Repository
  • 1 Watchers
  • 3 Stars
  • 658 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 26 Versions
  • 2 % Grown

The README.md

LightSpeed Provider for OAuth 2.0 Client

Build Status, (*1)

This package provides LightSpeed OAuth 2.0 support for the PHP League's OAuth 2.0 Client., (*2)

This package is compliant with PSR-1, PSR-2, PSR-4, and PSR-7. If you notice compliance oversights, please send a patch via pull request., (*3)

Requirements

The following versions of PHP are supported., (*4)

  • PHP 8.1
  • PHP 8.2
  • PHP 8.3
  • PHP 8.4
  • HHVM

Installation

Add the following to your composer.json file., (*5)

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

Usage

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 '<a href="'.$authUrl.'">Log in with LightSpeed!</a>';
    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 '<pre>';
    print_r($client); echo '<br>';
    print_r($sale); echo '<br>';
    echo '</pre>';

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

echo '

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

echo '
';

Testing

``` bash $ ./vendor/bin/phpunit, (*6)


## Upgrading ```bash vendor/bin/rector process src --dry-run

Contributing

Please see CONTRIBUTING for details., (*7)

Credits

License

The MIT License (MIT). Please see License File for more information., (*8)

The Versions

08/05 2018

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

08/05 2018

2.0.25

2.0.25.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

29/03 2018

2.0.24

2.0.24.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

22/02 2018

2.0.23

2.0.23.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

12/01 2018

2.0.22

2.0.22.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

29/08 2017

2.0.21

2.0.21.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

24/05 2017

2.0.20

2.0.20.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

24/03 2017

2.0.19

2.0.19.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

23/03 2017

2.0.18

2.0.18.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

13/02 2017

2.0.17

2.0.17.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

20/01 2017

2.0.16

2.0.16.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

18/01 2017

2.0.15

2.0.15.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

18/01 2017

2.0.14

2.0.14.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

16/01 2017

2.0.13

2.0.13.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

21/12 2016

2.0.11

2.0.11.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

19/12 2016

2.0.10

2.0.10.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

16/12 2016

2.0.9

2.0.9.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

21/11 2016

2.0.8

2.0.8.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

19/07 2016

2.0.6

2.0.6.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

14/07 2016

2.0.5

2.0.5.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

12/04 2016

2.0.3

2.0.3.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

08/04 2016

2.0.2

2.0.2.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

05/04 2016

2.0.1

2.0.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

31/03 2016

2.0.0

2.0.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

17/03 2016

1.0.2

1.0.2.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed

16/03 2016

1.0.0

1.0.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth client oauth2 lightspeed