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

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

privacyportal/oauth2-privacyportal
==================================

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

v0.1.1(2y ago)029.9k↓47.9%MITPHPPHP ^7.3 || ^8.0

Since Dec 6Pushed 2y agoCompare

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

READMEChangelog (2)Dependencies (4)Versions (4)Used By (0)

PrivacyPortal Provider for OAuth 2.0 Client
===========================================

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

[![Latest Version](https://camo.githubusercontent.com/6f9f3e3f8fe2529c78c4506ef99e6b5a94276491b972a0c3a7ad4f52d8aa4ff8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f70726976616379706f7274616c2f6f61757468322d70726976616379706f7274616c2e7376673f7374796c653d666c61742d737175617265)](https://github.com/privacyportal/oauth2-privacyportal/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![codecov](https://camo.githubusercontent.com/7a6bfb91aa3f484aaa544ade23b7449a8fa18f94e9351d555d974d41106c8760/68747470733a2f2f636f6465636f762e696f2f67682f70726976616379706f7274616c2f6f61757468322d70726976616379706f7274616c2f67726170682f62616467652e7376673f746f6b656e3d4751384931533439534e)](https://codecov.io/gh/privacyportal/oauth2-privacyportal)

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

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

[](#installation)

To install, use composer:

```
composer require privacyportal/oauth2-privacyportal

```

Usage
-----

[](#usage)

Usage is the same as The League's OAuth client, using `\League\OAuth2\Client\Provider\PrivacyPortal` as the provider.

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new League\OAuth2\Client\Provider\PrivacyPortal([
    'clientId'          => '{privacyportal-client-id}',
    'clientSecret'      => '{privacyportal-client-secret}',
    'redirectUri'       => 'https://example.com/callback-url',
]);

if (!isset($_GET['code'])) {

    // If we don't have an authorization code then get one
    $authUrl = $provider->getAuthorizationUrl();
    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: '.$authUrl);
    exit;

// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {

    unset($_SESSION['oauth2state']);
    exit('Invalid state');

} else {

    // Try to get an access token (using the authorization code grant)
    $token = $provider->getAccessToken('authorization_code', [
        'code' => $_GET['code']
    ]);

    // Optional: Now you have a token you can look up a users profile data
    try {

        // We got an access token, let's now get the user's details
        $user = $provider->getResourceOwner($token);

        // Use these details to create a new profile
        printf('Hello %s!', $user->getName());

    } catch (Exception $e) {

        // Failed to get user details
        exit('Oh dear...');
    }

    // Use this to interact with an API on the users behalf
    echo $token->getToken();
}
```

### Managing Scopes

[](#managing-scopes)

When creating your Privacy-Portal authorization URL, you can specify the state and scopes your application may authorize.

```
$options = [
    'state' => 'OPTIONAL_CUSTOM_CONFIGURED_STATE',
    'scope' => ['oidc','name','email'] // array or string; at least 'oidc' is required
];

$authorizationUrl = $provider->getAuthorizationUrl($options);
```

If neither are defined, the provider will utilize internal defaults.

At the time of authoring this documentation, the [following scopes are available](https://api.privacyportal.org/.well-known/openid-configuration).

- openid
- email
- name

Testing
-------

[](#testing)

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

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/privacyportal/oauth2-privacyportal/blob/master/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Steven Maguire](https://github.com/stevenmaguire)
- [Other Contributors](https://github.com/thephpleague/oauth2-github/contributors)

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

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.

###  Release Activity

Cadence

Every ~2 days

Total

2

Last Release

893d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/68805800a43f2063bcdbf319fd729eeef7b926162c562ef0d67ac02ba224aafa?d=identicon)[pp-composer](/maintainers/pp-composer)

---

Top Contributors

[![privacyguard](https://avatars.githubusercontent.com/u/92675882?v=4)](https://github.com/privacyguard "privacyguard (5 commits)")

---

Tags

clientoauthoauth2authorizationauthorisationprivacyportal

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[stevenmaguire/oauth2-keycloak

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

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)[mollie/oauth2-mollie-php

Mollie Provider for OAuth 2.0 Client

251.7M1](/packages/mollie-oauth2-mollie-php)[omines/oauth2-gitlab

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

36721.5k13](/packages/omines-oauth2-gitlab)

PHPackages © 2026

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