PHPackages                             fagundes/oauth2-eb - 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. fagundes/oauth2-eb

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

fagundes/oauth2-eb
==================

EB/DGP OAuth 2.0 support for PHP League's OAuth 2.0 Client

0.0.1(3y ago)06MITPHP

Since Apr 3Pushed 3y ago1 watchersCompare

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

READMEChangelogDependencies (3)Versions (2)Used By (0)

EB/DGP Provider for OAuth 2.0 Client
====================================

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

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

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

[](#installation)

```
composer require fagundes/oauth2-eb

```

Usage
-----

[](#usage)

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

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

    // Get state and store it to the session
    $_SESSION['oauth2state'] = $ebProvider->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 {
        $accessTokenAndResourceOwner = $ebProvider->getAccessToken(
            'authorization_code',
            [
                'code' => $_GET['code']
            ]
        );
    } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
        exit($e->getMessage());
    }

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

    // Now you can store the results to session etc.
    $_SESSION['accessToken'] = $accessTokenAndResourceOwner->getToken();
    $_SESSION['resourceOwner'] = $accessTokenAndResourceOwner->getId();

    var_dump(
        $accessTokenAndResourceOwner->getIdentidade(),
        $accessTokenAndResourceOwner->getNomeGuerra(),
        $accessTokenAndResourceOwner->getOrgaoSigla(),
        $accessTokenAndResourceOwner->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/fagundes/oauth2-eb/blob/master/LICENSE) for more information.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

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

1140d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2a488c4d3cfa2f8b3759d907c04cd7da9d347a25090424efbd7b8f1b57937543?d=identicon)[fagundes](/maintainers/fagundes)

---

Tags

phpapiclientAuthenticationoauthoauth2authorizationebExército BrasileiroDGPDepartamento-Geral do Pessoal

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fagundes-oauth2-eb/health.svg)

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

###  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.0M66](/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)
