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

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

bybrand/oauth2-teamwork
=======================

Teamwork Provider for PHP League's OAuth 2.0 Client

v1.0.0(4y ago)119MITPHP

Since Sep 15Pushed 4y ago1 watchersCompare

[ Source](https://github.com/bybrand/oauth2-teamwork)[ Packagist](https://packagist.org/packages/bybrand/oauth2-teamwork)[ RSS](/packages/bybrand-oauth2-teamwork/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

Teamwork Provider for PHP OAuth 2.0 Client
==========================================

[](#teamwork-provider-for-php-oauth-20-client)

This package provides Teamwork OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client). Work with Teamwork API (v2). Initially, this module was used for the integration of [Bybrand](https://www.bybrand.io) with Teamwork Desk and is in production.

Full documentation, can be see in [Teamwork documentation](https://developer.teamwork.com/). Also, you can read the [App Login Flow](https://developer.teamwork.com/guides/how-to-authenticate-via-app-login-flow/).

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

[](#installation)

```
composer require bybrand/oauth2-teamwork

```

Usage
-----

[](#usage)

This is a instruction base to get the token, and in then, to save in your database to future request.

```
use Bybrand\OAuth2\Client\Provider\Teamwork as ProviderTeamwork;
use Bybrand\OAuth2\Client\OptionProvider\JsonAuthOptionProvider;

$params = $_GET;

$provider = new ProviderTeamwork([
    'clientId'     => 'key-id',
    'clientSecret' => 'secret-key',
    'redirectUri'  => 'your-url-redirect'
]);

// Need to Json authentication and not the default x-www-form-urlencoded
$provider->setOptionProvider(new JsonAuthOptionProvider)

if (!isset($params['code']) or empty($params['code'])) {
    // If we don't have an authorization code then get one
    $authorizationUrl = $provider->getAuthorizationUrl();

    // Get state and store it to the session
    $_SESSION['oauth2state'] = $provider->getState();

    header('Location: '.$authorizationUrl);
    exit;
// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($params['state']) || ($params['state'] !== $_SESSION['oauth2state'])) {
    unset($_SESSION['oauth2state']);

    // Set error and redirect.
    echo 'Invalid stage';
} else {
    try {
        // Try to get an access token (using the authorization code grant)
        $token = $provider->getAccessToken('client_credentials', [
            'code' => $params['code']
        ]);
    } catch (\Exception $e) {
        // Error, make redirect or message.
    }

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

    // Basic information about the installation.
    $installation = $token->getValues()['installation'];
}

```

Please, for more information see the PHP League's general usage examples.

Refreshing a Token
------------------

[](#refreshing-a-token)

Teamwork tokens do not expire and do not need to be refreshed.

Testing
-------

[](#testing)

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

```

License
-------

[](#license)

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

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

Total

4

Last Release

1743d ago

Major Versions

v0.0.3 → v1.0.02021-09-16

### Community

Maintainers

![](https://www.gravatar.com/avatar/0db1c7d7836cb218fe710bb074fa076dad1961a92e31ccbf6e7528ab7a8d07cf?d=identicon)[bybrand](/maintainers/bybrand)

---

Top Contributors

[![ursoforte](https://avatars.githubusercontent.com/u/578063?v=4)](https://github.com/ursoforte "ursoforte (6 commits)")

---

Tags

oauth2phpphpapiAuthenticationoauth2authorizationteamwork

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[andalisolutions/oauth2-anaf

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

195.9k](/packages/andalisolutions-oauth2-anaf)

PHPackages © 2026

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