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

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

youthweb/oauth2-youthweb
========================

Youthweb OAuth 2.0 Client Provider

1.2.0(5y ago)27.1k11GPL-3.0-or-laterPHPPHP ^7.4 || ^8.0

Since Oct 14Pushed 5y ago3 watchersCompare

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

READMEChangelog (5)Dependencies (2)Versions (6)Used By (1)

Youthweb Provider for OAuth 2.0 Client
======================================

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

[![Latest Version](https://camo.githubusercontent.com/3de9180d6c67a8f2191c1aa251c12e3bc2071b1687fb4296ed22085dadf286f2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f796f7574687765622f6f61757468322d796f7574687765622e737667)](https://github.com/youthweb/oauth2-youthweb/releases)[![Software License GLPv3](https://camo.githubusercontent.com/4669e8a742df15415ba0bd590680d79635a2f84326cc8e09c051b537843077ca/687474703a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d47504c76332d627269676874677265656e2e737667)](LICENSE)[![Build Status](https://camo.githubusercontent.com/ab42f610060497cc4e2a4ce166e290e7640eb4f7e72e4033f2354ce8b2147781/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f796f7574687765622f6f61757468322d796f7574687765622e737667)](https://travis-ci.org/youthweb/oauth2-youthweb)[![Coverage Status](https://camo.githubusercontent.com/2df797f464d88e3fb89b1bc1dfa7793c2c55f707f5d40f82ba73e556b9e51f2d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f796f7574687765622f6f61757468322d796f7574687765622f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/youthweb/oauth2-youthweb?branch=master)[![Gitter](https://camo.githubusercontent.com/abe08b740a4156153736f791393ec4da6619c4be73212e75769f52edacc0e2b5/68747470733a2f2f6261646765732e6769747465722e696d2f4a6f696e253230436861742e737667)](https://gitter.im/youthweb/youthweb-api?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

This package provides [Youthweb OAuth 2.0 support](https://developer.youthweb.net/api_general_oauth2.html) for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

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

[](#installation)

To install, use composer:

```
composer require youthweb/oauth2-youthweb

```

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new Youthweb\OAuth2\Client\Provider\Youthweb([
    'clientId'          => '{youthweb-client-id}',
    'clientSecret'      => '{youthweb-client-secret}',
    'redirectUri'       => 'https://example.org/callback-url',
    'apiVersion'        => '0.15', // optional
]);

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->getNickname());
    }
    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 Youthweb authorization URL, you can specify the state and scopes your application may authorize.

```
$options = [
    'state' => 'OPTIONAL_CUSTOM_CONFIGURED_STATE',
    'scope' => ['user:read', 'user:email'] // array or string
];

$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 with Youthweb-API 0.15:

- post:read
- post:write
- user:read
- user:email

See [here](https://developer.youthweb.net/api_general_scopes.html) for more information.

Testing
-------

[](#testing)

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

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

[](#contributing)

Please feel free to fork and sending Pull Requests. This project follows [Semantic Versioning 2](http://semver.org) and [PSR-2](https://www.php-fig.org/psr/psr-2/).

Credits
-------

[](#credits)

- [All Contributors](https://github.com/youthweb/oauth2-youthweb/contributors)

License
-------

[](#license)

GPL3. Please see [License File](LICENSE) for more information.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 93.5% 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 ~400 days

Total

5

Last Release

1894d ago

PHP version history (4 changes)1.0.0PHP &gt;=5.6.0

1.0.2PHP ^5.6 || ^7.0

1.1.0PHP ^7.2

1.2.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ad0c0fa748422ad817c4124a06618a1e655995502be8d6f03d699f38c0d56b0?d=identicon)[Art4](/maintainers/Art4)

---

Top Contributors

[![Art4](https://avatars.githubusercontent.com/u/2162994?v=4)](https://github.com/Art4 "Art4 (29 commits)")[![ishyevandro](https://avatars.githubusercontent.com/u/1781740?v=4)](https://github.com/ishyevandro "ishyevandro (2 commits)")

---

Tags

clientoauthoauth2authorizationauthorisationyouthweb

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  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)
