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

02.0kPHP

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 2d 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 18% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity22

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://avatars.githubusercontent.com/u/224733?v=4)[Johan Cwiklinski](/maintainers/trasher)[@trasher](https://github.com/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

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.3M17](/packages/kartik-v-yii2-password)[vitalybaev/laravel5-dkim

Laravel 5/6 package for signing outgoing messages with DKIM.

3163.1k](/packages/vitalybaev-laravel5-dkim)

PHPackages © 2026

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