PHPackages                             league/oauth1-trello - 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. league/oauth1-trello

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

league/oauth1-trello
====================

Trello OAuth 1.0 Client Provider for The PHP League OAuth1-Client

3531PHP

Since Dec 28Pushed 10y ago7 watchersCompare

[ Source](https://github.com/thephpleague/oauth1-trello)[ Packagist](https://packagist.org/packages/league/oauth1-trello)[ RSS](/packages/league-oauth1-trello/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Trello Provider for OAuth 1.0 Client
====================================

[](#trello-provider-for-oauth-10-client)

[![Latest Version](https://camo.githubusercontent.com/e344f7ee5e34db275f39046c79235da9453132dfb3b71520e2828bfbe85f84fe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7468657068706c65616775652f6f61757468312d7472656c6c6f2e7376673f7374796c653d666c61742d737175617265)](https://github.com/thephpleague/oauth1-trello/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/bf7bfc319760a3ec451317462288cec06812c8e8752d65f5e576d0fe03f31d04/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7468657068706c65616775652f6f61757468312d7472656c6c6f2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/thephpleague/oauth1-trello)[![Coverage Status](https://camo.githubusercontent.com/9adddbe6d2d0922ce0d1682f7fa1a43b62b4bed0e05a30634dc61fbc3e56a16e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f7468657068706c65616775652f6f61757468312d7472656c6c6f2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/thephpleague/oauth1-trello/code-structure)[![Quality Score](https://camo.githubusercontent.com/938fc69abebbad9567c14e5e52785c92d3df77f8ad2f3cefd818102aa109c21e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7468657068706c65616775652f6f61757468312d7472656c6c6f2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/thephpleague/oauth1-trello)[![Total Downloads](https://camo.githubusercontent.com/a8c3a732161a22b3fb017a80c5989e3d87ad6ca9ca93f8e43521288873c2c05a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c65616775652f6f61757468312d7472656c6c6f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/league/oauth1-trello)

This package provides Trello OAuth 1.0 support for the PHP League's [OAuth 1.0 Client](https://github.com/thephpleague/oauth1-client).

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

[](#installation)

To install, use composer:

```
composer require league/oauth1-trello

```

Usage
-----

[](#usage)

Usage is the same as The League's OAuth client, using `\League\OAuth1\Client\Server\Trello` as the server.

### Authenticating with OAuth 1.0

[](#authenticating-with-oauth-10)

```
// Create a server instance.
$server = new \League\OAuth1\Client\Server\Trello([
    'identifier'              => 'your-identifier',
    'secret'                  => 'your-secret',
    'callbackUri'             => 'http://your-callback-uri/',
    // The following can be used to set defaults for the server
    'scope'                   => 'read',
    'expiration'              => '1day',
    'name'                    => 'Trello App'
]);

// Obtain Temporary Credentials and User Authorization
if (!isset($_GET['oauth_token'], $_GET['oauth_verifier'])) {

    // First part of OAuth 1.0 authentication is to
    // obtain Temporary Credentials.
    $temporaryCredentials = $server->getTemporaryCredentials();

    // Store credentials in the session, we'll need them later
    $_SESSION['temporary_credentials'] = serialize($temporaryCredentials);
    session_write_close();

    // Second part of OAuth 1.0 authentication is to obtain User Authorization
    // by redirecting the resource owner to the login screen on the server.
    // Create an authorization url.
    $authorizationUrl = $server->getAuthorizationUrl($temporaryCredentials);

    // Redirect the user to the authorization URL. The user will be redirected
    // to the familiar login screen on the server, where they will login to
    // their account and authorize your app to access their data.
    header('Location: ' . $authorizationUrl);
    exit;

// Obtain Token Credentials
} else {

    try {

        // Retrieve the temporary credentials we saved before.
        $temporaryCredentials = unserialize($_SESSION['temporary_credentials']);

        // We will now obtain Token Credentials from the server.
        $tokenCredentials = $server->getTokenCredentials(
            $temporaryCredentials,
            $_GET['oauth_token'],
            $_GET['oauth_verifier']
        );

        // We have token credentials, which we may use in authenticated
        // requests against the service provider's API.
        echo $tokenCredentials->getIdentifier() . "\n";
        echo $tokenCredentials->getSecret() . "\n";

        // Using the access token, we may look up details about the
        // resource owner.
        $resourceOwner = $server->getResourceOwner($tokenCredentials);

        var_export($resourceOwner->toArray());

        // The server provides a way to get an authenticated API request for
        // the service, using the access token; it returns an object conforming
        // to Psr\Http\Message\RequestInterface.
        $request = $server->getAuthenticatedRequest(
            'GET',
            'http://your.service/endpoint',
            $tokenCredentials
        );

    } catch (\League\OAuth1\Client\Exceptions\Exception $e) {

        // Failed to get the token credentials or user details.
        exit($e->getMessage());

    }

}
```

### Configuring your server

[](#configuring-your-server)

In order to complete the authorization flow with your user, you will need to provide three additional pieces of information.

namedescription`scope`Scope informs the Trello service about which permissions you are requesting on behalf of your user. `read` or `read,write``expiration`Expiration informs the Trello service about how long you are requesting this permissions. `1day`, `3days`, `never``name`Name informs the Trello service about the name of your application. This will be displayed to your users during authorization.You may configure your server to include this information when creating the server.

```
// Create a server instance.
$server = new \League\OAuth1\Client\Server\Trello([
    'identifier'              => 'your-identifier',
    'secret'                  => 'your-secret',
    'callbackUri'             => 'http://your-callback-uri/',
    'scope'                   => 'read',
    'expiration'              => '1day',
    'name'                    => 'Trello App'
]);
```

You may also provide this information when creating your authorization url.

```
// Create a server instance.
$server = new \League\OAuth1\Client\Server\Trello([
    'identifier'              => 'your-identifier',
    'secret'                  => 'your-secret',
    'callbackUri'             => 'http://your-callback-uri/',
]);

$temporaryCredentials = $server->getTemporaryCredentials();

$options = [
    'scope'                   => 'read',
    'expiration'              => '1day',
    'name'                    => 'Trello App'
];

$authorizationUrl = $server->getAuthorizationUrl($temporaryCredentials, $options);
```

Configuration provided when creating your authorization url with take precedence over default configuration.

### Sending one-off requests

[](#sending-one-off-requests)

You may use the server to create authenticated requests for one-off or trivial needs. If your needs are more robust, [trello-php](https://github.com/stevenmaguire/trello-php) is recommended.

```
$server = new \League\OAuth1\Client\Server\Trello([
    'identifier'              => 'your-identifier',
    'secret'                  => 'your-secret',
    'callbackUri'             => 'http://your-callback-uri/',
]);

$token = 'your-resource-owner-token';
$secret = 'your-resource-owner-secret';

$tokenCredentials = new \League\OAuth1\Client\Credentials\TokenCredentials($token, $secret);

$request = $server->getAuthenticatedRequest(
    'get',
    'https://api.trello.com/1/members/me/boards',
    $tokenCredentials
);

$client = new \GuzzleHttp\Client();

$response = $client->send($request);
```

### Running the included example

[](#running-the-included-example)

This project contains some example code within the `example` directory at the root of this project.

First, open the `example/index.php` file and update the server configuration with your Trello App Identifier and Secret.

Then run the code in your browser. Using the built-in server provided by PHP may be the fastest options. From the command line, and at the root of the project running the following command.

```
php -S localhost:9000 -t example
```

The built-in web server should begin running and when you browse to [`http://localhost:9000`](http://localhost:9000) in your favorite browser, you can begin testing your configuration.

Testing
-------

[](#testing)

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

```
$ ./vendor/bin/phpcs src --standard=psr2 -sp
```

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/thephpleague/oauth1-trello/blob/master/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Steven Maguire](https://github.com/stevenmaguire)
- [All Contributors](https://github.com/thephpleague/oauth1-trello/contributors)

License
-------

[](#license)

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

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8d9c05a30823ae19fc54aa4b4721a696c253f8dec10c7fd22d372cfdc0fcb36d?d=identicon)[stevenmaguire](/maintainers/stevenmaguire)

---

Top Contributors

[![stevenmaguire](https://avatars.githubusercontent.com/u/1851973?v=4)](https://github.com/stevenmaguire "stevenmaguire (8 commits)")

### Embed Badge

![Health badge](/badges/league-oauth1-trello/health.svg)

```
[![Health](https://phpackages.com/badges/league-oauth1-trello/health.svg)](https://phpackages.com/packages/league-oauth1-trello)
```

###  Alternatives

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.2M17](/packages/kartik-v-yii2-password)

PHPackages © 2026

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