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

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

aporat/oauth2-pinterest
=======================

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

1.0.2(1y ago)0841↑25%MITPHPPHP  ^8.1CI passing

Since Mar 20Pushed 5mo ago1 watchersCompare

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

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

Pinterest Provider for OAuth 2.0 Client
=======================================

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

[![Latest Stable Version](https://camo.githubusercontent.com/538eaca2867aed93cbf95fe685b8a248ebf034f641edf21b389a8a6699173cf0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61706f7261742f6f61757468322d70696e7465726573742e7376673f6c6f676f3d636f6d706f736572)](https://packagist.org/packages/aporat/oauth2-pinterest)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE)[![codecov](https://camo.githubusercontent.com/d543da062d499ff93d02e9abffd5140f3c0689bf96fff314691337e580513622/68747470733a2f2f636f6465636f762e696f2f6769746875622f61706f7261742f6f61757468322d70696e7465726573742f67726170682f62616467652e7376673f746f6b656e3d585a32313032534c4148)](https://codecov.io/github/aporat/oauth2-pinterest)[![GitHub Actions Workflow Status](https://github.com/aporat/oauth2-pinterest/actions/workflows/ci.yml/badge.svg)](https://github.com/aporat/oauth2-pinterest/actions/workflows/ci.yml/badge.svg)[![Total Downloads](https://camo.githubusercontent.com/5900f600024dce00645882e85ec117cdae642a43d307211c64737e27e5276027/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61706f7261742f6f61757468322d70696e7465726573742e737667)](https://packagist.org/packages/aporat/oauth2-pinterest)

This package provides Pinterest 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 aporat/oauth2-pinterest

```

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new Aporat\OAuth2\Client\Provider\Pinterest([
    'clientId'          => '{pinterest-client-id}',
    'clientSecret'      => '{pinterest-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->getUsername());

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

```
$options = [
    'state' => 'OPTIONAL_CUSTOM_CONFIGURED_STATE',
    'scope' => ['user_accounts','pins'] // array or string; at least 'user:email' is required
];

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

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

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

License
-------

[](#license)

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

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance61

Regular maintenance activity

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80.8% 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

2

Last Release

418d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/54592564aa6e76cb00fdb16a8b7fadaea333de11da7fd8a739fe4812237a551c?d=identicon)[aporat](/maintainers/aporat)

---

Top Contributors

[![aporat](https://avatars.githubusercontent.com/u/415576?v=4)](https://github.com/aporat "aporat (21 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")

---

Tags

clientoauthoauth2authorizationauthorisationpinterest

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

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