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

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

pizdata/oauth2-shopify
======================

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

v1.0.1(9y ago)1533.8k4MITPHPPHP ~5.6|~7.0CI failing

Since Mar 28Pushed 4y ago2 watchersCompare

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

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

Shopify OAuth 2.0 Client Provider
=================================

[](#shopify-oauth-20-client-provider)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d0be20619f736434d9586c764dfdafe188d74161771402531e6b30474772cd3a/68747470733a2f2f706f7365722e707567782e6f72672f70697a646174612f6f61757468322d73686f706966792f762f737461626c65)](https://packagist.org/packages/pizdata/oauth2-shopify)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/a9977c9745d6a45c85a91026736f33f5b2b244b060da9d8274afc3c91df48ead/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f70697a646174612f6f61757468322d73686f706966792d7068702f6d61737465722e737667)](https://travis-ci.org/pizdata/oauth2-shopify-php)[![Coverage Status](https://camo.githubusercontent.com/e773a6353da5491820c0410191c77d64424037c20d4db5dd6b8af680a9368553/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f70697a646174612f6f61757468322d73686f706966792d7068702e737667)](https://scrutinizer-ci.com/g/pizdata/oauth2-shopify-php/code-structure)[![Quality Score](https://camo.githubusercontent.com/bfb61f8d76647ac3f7c6f42d993c95302d1302e67997714d2a5d3bc21d020c8d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f70697a646174612f6f61757468322d73686f706966792d7068702e737667)](https://scrutinizer-ci.com/g/pizdata/oauth2-shopify-php)[![Total Downloads](https://camo.githubusercontent.com/0bddc720aca5abc66116b72b7cf09905f87241d0ad0931a9b2544d8975996077/68747470733a2f2f706f7365722e707567782e6f72672f70697a646174612f6f61757468322d73686f706966792f646f776e6c6f616473)](https://packagist.org/packages/pizdata/oauth2-shopify)

[Shopify OAuth 2.0](https://help.shopify.com/api/getting-started/authentication/oauth) Client Provider.

Install
-------

[](#install)

Via Composer

```
$ composer require pizdata/oauth2-shopify
```

Usage
-----

[](#usage)

```
$provider = new Pizdata\OAuth2\Client\Provider\Shopify([
    'clientId'                => '{shopify-client-id}',    // The client ID assigned to you by the Shopify
    'clientSecret'            => '{shopify-client-secret}',   // The client password assigned to you by the Shopify
    'redirectUri'             => 'http://localhost/callback', // The redirect URI assigned to you
    'shop'                    => 'pizdata.myshopify.com', // The Shop name
]);

// If we don't have an authorization code then get one
if (!isset($_GET['code'])) {

    // Setting up scope
    $options = [
        'scope' => [
            'read_content', 'write_content',
            'read_themes', 'write_themes',
            'read_products', 'write_products',
            'read_customers', 'write_customers',
            'read_orders', 'write_orders',
            'read_draft_orders', 'write_draft_orders',
            'read_script_tags', 'write_script_tags',
            'read_fulfillments', 'write_fulfillments',
            'read_shipping', 'write_shipping',
            'read_analytics',
        ]
    ];
    // Fetch the authorization URL from the provider; this returns the
    // urlAuthorize option and generates and applies any necessary parameters
    // (e.g. state).
    $authorizationUrl = $provider->getAuthorizationUrl($options);

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

    // Redirect the user to the authorization URL.
    header('Location: ' . $authorizationUrl);
    exit;

// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || (isset($_SESSION['oauth2state']) && $_GET['state'] !== $_SESSION['oauth2state'])) {

    if (isset($_SESSION['oauth2state'])) {
        unset($_SESSION['oauth2state']);
    }

    exit('Invalid state');

} else {

    try {
        // Try to get an access token using the authorization code grant.
        $accessToken = $provider->getAccessToken('authorization_code', [
            'code' => $_GET['code']
        ]);

        $store = $provider->getResourceOwner($accessToken);

        // Access to Store base information
        echo $store->getName();
        echo $store->getEmail();
        echo $store->getDomain();

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

    } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
        // Failed to get the access token or user details.
        exit($e->getMessage());

    }
}
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Roman Sevastyanov](https://github.com/sevastyanovio)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

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

3

Last Release

3330d ago

Major Versions

v0.1.0 → v1.0.02017-03-29

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23269048?v=4)[davex69](/maintainers/davex69)[@davex69](https://github.com/davex69)

---

Top Contributors

[![sevastyanovio](https://avatars.githubusercontent.com/u/1830504?v=4)](https://github.com/sevastyanovio "sevastyanovio (24 commits)")[![tahrz](https://avatars.githubusercontent.com/u/38757318?v=4)](https://github.com/tahrz "tahrz (1 commits)")

---

Tags

shopifyshopify-apishopify-oauthshopify-phpclientoauthoauth2authorizationauthorisationshopifypizdata

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

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