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

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

galette/oauth2-galette
======================

Galette OAuth 2.0 support for the PHP League's OAuth 2.0 client

01.2kPHP

Since Jan 28Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

Galette Provider for OAuth 2.0 Client
=====================================

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

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

The [Galette OAuth plugin](https://galette-community.github.io/plugin-oauth2/) must be installed on you [Galette](https://galette.eu) instance.

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

[](#installation)

```
composer require galette-community/oauth2-galette
```

Usage
-----

[](#usage)

```
$galetteProvider = new \Galette\OAuth2\Client\Provider\Galette([
    //information related to the app where you will use galette-oauth2
    'clientId'      => 'yourId',          // The client ID assigned to you
    'clientSecret'  => 'yourSecret',      // The client password assigned to you
    'redirectUri'   => 'yourRedirectUri', // The return URL you specified for your app
    //information related to the galette instance you want to connect to
    'instance'      => 'yourInstance',    // The instance of Galette you want to connect to
    'pluginDir'     => 'yourPluginDir',   // The directory where the plugin is installed - defaults to 'plugin-oauth2'
]);

// Get authorization code
if (!isset($_GET['code'])) {
    // Options are optional, defaults to 'read_prefs' only
    $options = ['instance' => 'https://my.galette'];

    // Get authorization URL
    $authorizationUrl = $galetteProvider->getAuthorizationUrl($options);

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

    // Get resource owner
    try {
        $resourceOwner = $galetteProvider->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->getEmail(),
        $resourceOwner->getUsername(),
        $resourceOwner->getLang(),
        $resourceOwner->getStatus(),
        $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/jbelien/oauth2-openstreetmap/blob/master/LICENSE) for more information.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/50348be212ab6478818bc77ee3ceacf35ee49cbaf0f2fc822db7f07f406d7a80?d=identicon)[trasher](/maintainers/trasher)

---

Top Contributors

[![trasher](https://avatars.githubusercontent.com/u/224733?v=4)](https://github.com/trasher "trasher (2 commits)")

### Embed Badge

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

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

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

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

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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