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

ActiveLibrary

worksection/oauth2-worksection
==============================

Worksection OAuth 2.0 support for the PHP League's OAuth 2.0 Client

1.4.3(2y ago)07.4k↓100%MITPHPPHP &gt;=7.2

Since Sep 13Pushed 2y ago1 watchersCompare

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

READMEChangelog (4)Dependencies (1)Versions (10)Used By (0)

Worksection Provider for OAuth 2.0 Client
=========================================

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

This package provides Worksection OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client). Worksection FAQ about [OAuth2.0](https://worksection.com/en/faq/oauth.html)

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

[](#installation)

```
composer require worksection/oauth2-worksection

```

Usage
-----

[](#usage)

```
use Worksection\OAuth2\Client\Provider\Worksection as WorksectionOauth2;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;

$provider = new WorksectionOauth2([
    'clientId'                => 'yourId',
    'clientSecret'            => 'yourSecret',
    'redirectUri'             => 'https://redirecturl.com/query'
]);

if (!$_REQUEST['code']) {
    $authorizationUrl = $provider->getAuthorizationUrl(['scope' => 'projects_read users_write']);
    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: ' . $authorizationUrl);

} elseif ($_REQUEST['state']) {
    if ($_REQUEST['state'] !== $_SESSION['oauth2state']) {
        exit('Invalid state');
    } else {
        unset($_SESSION['oauth2state']);
    }

    // Access token
    try {
        $accessToken = $provider->getAccessToken('authorization_code', ['code' => $_GET['code']]);
    } catch (IdentityProviderException $e) {
        exit($e->getMessage());
    }

    // Resource info
    try {
        $resourceOwner = $provider->getResourceOwner($accessToken);
    } catch (IdentityProviderException $e) {
        exit($e->getMessage());
    }

    //echo 'Access Token: ' . $accessToken->getToken();
    //echo 'Refresh Token: ' . $accessToken->getRefreshToken();
    //echo 'Account URL: ' . $accessToken->getValues()['account_url'];
    //echo 'Expired in: ' . $accessToken->getExpires();
    //echo 'Resource Owners ID: ' . $resourceOwner->getId();
    //echo 'Resource Owners NAME: ' . $resourceOwner->getName();
    //echo 'Resource Owners EMAIL: ' . $resourceOwner->getEmail();
    //echo 'Resource Owners Account URL: ' . $resourceOwner->getAccountUrl();

    // Make some API request using Access Token
    $options = [
        'body' => json_encode([
            'action' => 'get_tasks',
            'page' => '/project/193/'
        ]),
        'headers' => [
            'Content-Type' => 'application/json'
        ]
    ];
    $request = $provider->getAuthenticatedRequest('POST', $resourceOwner->getAccountUrl() . '/api/oauth2', $accessToken, $options);
    try {
        $response = $provider->getParsedResponse($request);
    } catch (IdentityProviderException $e) {
        exit($e->getMessage());
    }
    var_dump($response);
}
```

For more information see the PHP League's general usage examples.

License
-------

[](#license)

The MIT License (MIT).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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 ~14 days

Recently: every ~23 days

Total

8

Last Release

870d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0305c909e718f5addcfac4947fa258274c167f4baf16cab960a141a24d95f7f8?d=identicon)[Worksection](/maintainers/Worksection)

---

Top Contributors

[![vadymskk](https://avatars.githubusercontent.com/u/68269374?v=4)](https://github.com/vadymskk "vadymskk (15 commits)")

### Embed Badge

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

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

###  Alternatives

[league/oauth2-google

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

41721.2M118](/packages/league-oauth2-google)[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2509.6M48](/packages/thenetworg-oauth2-azure)[stevenmaguire/oauth2-keycloak

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

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k17](/packages/civicrm-civicrm-core)[tempest/framework

The PHP framework that gets out of your way.

2.1k23.1k9](/packages/tempest-framework)[xeroapi/xero-php-oauth2

Xero official PHP SDK for oAuth2 generated with OpenAPI spec 3

1054.3M14](/packages/xeroapi-xero-php-oauth2)

PHPackages © 2026

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