PHPackages                             gugiman/oauth2-ebay - 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. gugiman/oauth2-ebay

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

gugiman/oauth2-ebay
===================

Ebay OAuth 2.0 support for the PHP League's OAuth 2.0 Client

1.0.0(1y ago)135MITPHPPHP &gt;=7.4

Since Jan 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Gugiman/oauth2-ebay)[ Packagist](https://packagist.org/packages/gugiman/oauth2-ebay)[ Docs](https://github.com/Gugiman/oauth2-ebay)[ RSS](/packages/gugiman-oauth2-ebay/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Ebay Provider for OAuth 2.0 Client
==================================

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

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

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

[](#installation)

```
composer require gugiman/oauth2-ebay

```

Usage
-----

[](#usage)

```
$ebayProvider = new \Gugiman\OAuth2\Client\Provider\Ebay([
    'clientId'                => 'yourId',          // The client ID assigned to you by Ebay
    'clientSecret'            => 'yourSecret',      // The client password assigned to you by Ebay
    'redirectUri'             => 'yourRedirectUri'  // The return URL you specified for your app on Ebay
]);

// Get authorization code
if (!isset($_GET['code'])) {
    // Get authorization URL
    $authorizationUrl = $ebayProvider->getAuthorizationUrl();

    // Get state and store it to the session
    $_SESSION['oauth2state'] = $ebayProvider->getState();

    // Redirect user to authorization URL
    header('Location: ' . $authorizationUrl);
    exit;
// Check for errors
} elseif (empty($_GET['state']) || (isset($_SESSION['oauth2state']) && $_GET['state'] !== $_SESSION['oauth2state'])) {
    if (isset($_SESSION['oauth2state'])) {
        unset($_SESSION['oauth2state']);
    }
    exit('Invalid state');
} else {
    // Get access token
    try {
        $accessToken = $ebayProvider->getAccessToken(
            'authorization_code',
            [
                'code' => $_GET['code']
            ]
        );

        // We have an access token, which we may use in authenticated
        // requests against the service provider's API.
        echo 'Access Token: ' . $tokens->getToken() . "";
        echo 'Refresh Token: ' . $tokens->getRefreshToken() . "";
        echo 'Expired in: ' . $tokens->getExpires() . "";
        echo 'Already expired? ' . ($tokens->hasExpired() ? 'expired' : 'not expired') . "";

    } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
        exit($e->getMessage());
    }

    // Get resource owner
    try {
        $resourceOwner = $ebayProvider->getResourceOwner($accessToken);
    } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
        exit($e->getMessage());
    }

    // Now you can store the results to session etc.
    $_SESSION['accessToken'] = $accessToken;
    $_SESSION['resourceOwner'] = $resourceOwner;

    var_dump(
        $resourceOwner->getId(),
        $resourceOwner->getUserName(),
        $resourceOwner->getAccountType(),
        $resourceOwner->getRegistrationMarketplaceId(),
        $resourceOwner->toArray()
    );
}
```

For more information see the PHP League's general usage examples.

Testing
-------

[](#testing)

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

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance45

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 75% 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

Unknown

Total

1

Last Release

464d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a49c0de62b2038e2e4bdf76a1cc581fe98e9f9d213dc2e259b05b0811c8cc28e?d=identicon)[Gugiman](/maintainers/Gugiman)

---

Top Contributors

[![dsteffenHbH](https://avatars.githubusercontent.com/u/118165273?v=4)](https://github.com/dsteffenHbH "dsteffenHbH (3 commits)")[![Gugiman](https://avatars.githubusercontent.com/u/5836639?v=4)](https://github.com/Gugiman "Gugiman (1 commits)")

---

Tags

ebayoauthoauth2oauth2-clientphpphpapiclientAuthenticationoauthoauth2authorizationebay

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gugiman-oauth2-ebay/health.svg)

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

###  Alternatives

[league/oauth2-google

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

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

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

32013.0M65](/packages/league-oauth2-facebook)[andalisolutions/oauth2-anaf

Anaf OAuth 2.0 support for the PHP League's OAuth 2.0 Client

194.1k](/packages/andalisolutions-oauth2-anaf)

PHPackages © 2026

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