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

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

multidimensional/oauth2-shopify
===============================

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

v1.0.2(1y ago)929.1k—10%7MITPHPPHP  &gt;=8.2 &lt;8.5.0CI passing

Since Dec 21Pushed 1y ago1 watchersCompare

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

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

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

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

[![Latest Stable Version](https://camo.githubusercontent.com/bab93929452adb44a76ba7614bd21dd7be09fcd0bf9f508692ebcc797ccd0ff5/68747470733a2f2f706f7365722e707567782e6f72672f6d756c746964696d656e73696f6e616c2f6f61757468322d73686f706966792f762f737461626c65)](https://packagist.org/packages/multidimensional/oauth2-shopify)[![Total Downloads](https://camo.githubusercontent.com/4ec018fbec2e61d2caaba0244456fe7dbbae61d2e639e321070ce80627d431b9/68747470733a2f2f706f7365722e707567782e6f72672f6d756c746964696d656e73696f6e616c2f6f61757468322d73686f706966792f646f776e6c6f616473)](https://packagist.org/packages/multidimensional/oauth2-shopify)[![License](https://camo.githubusercontent.com/1a7d2f438f5d9fef38ba2d2091e9b10abe180fbfe46951277748aa06165c650e/68747470733a2f2f706f7365722e707567782e6f72672f6d756c746964696d656e73696f6e616c2f6f61757468322d73686f706966792f6c6963656e7365)](https://packagist.org/packages/multidimensional/oauth2-shopify)[![CI](https://github.com/multidimension-al/oauth2-shopify/actions/workflows/ci.yml/badge.svg)](https://github.com/multidimension-al/oauth2-shopify/actions/workflows/ci.yml)[![codecov](https://camo.githubusercontent.com/ec238b73094e82b2d2fd6d3d696731f51f76145a23df7980ea09a790e764c2e8/68747470733a2f2f636f6465636f762e696f2f6769746875622f6d756c746964696d656e73696f6e2d616c2f6f61757468322d73686f706966792f67726170682f62616467652e7376673f746f6b656e3d414d4c4e5249504b414a)](https://codecov.io/github/multidimension-al/oauth2-shopify)

This package provides Shopify's 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 multidimensional/oauth2-shopify

```

### Usage

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new Multidimensional\OAuth2\Client\Provider\Shopify([
    'clientId'          => '{shopify-app-id}',
    'clientSecret'      => '{shopify-app-secret}',
    'shop'              => 'example.myshopify.com',
    'redirectUri'       => 'https://example.com/callback-url',
]);

if (!isset($_GET['code'])) {
    $options = [
        'scope' => ['read_orders','write_orders'] // array or string
    ];

    // If we don't have an authorization code then get one
    $authUrl = $provider->getAuthorizationUrl($options);
    $_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->getName());

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

```
$options = [
    'state' => 'OPTIONAL_CUSTOM_CONFIGURED_STATE',
    'scope' => ['read_orders','write_orders'] // array or string
];

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

If neither are defined, the provider will utilize internal defaults.

At the time of authoring this documentation, the [following scopes are available](https://help.shopify.com/api/guides/authentication/oauth#scopes).

- read\_content, write\_content- Access to Article, Blog, Comment, Page, and Redirect.
- read\_themes, write\_themes - Access to Asset and Theme.
- read\_products, write\_products - Access to Product, product variant, Product Image, Collect, Custom Collection, and Smart Collection.
- read\_customers, write\_customers - Access to Customer and Saved Search.
- read\_orders, write\_orders - Access to Order, Transaction and Fulfillment.
- read\_script\_tags, write\_script\_tags - Access to Script Tag.
- read\_fulfillments, write\_fulfillments - Access to Fulfillment Service.
- read\_shipping, write\_shipping - Access to Carrier Service.
- read\_analytics - Access to Analytics API.
- read\_users, write\_users - Access to User SHOPIFY PLUS.

Testing
-------

[](#testing)

```
make composer-install
make phpunit
```

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

[](#contributing)

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

Credits
-------

[](#credits)

- [Nile Suan](https://github.com/nilesuan)
- [arnaudbagnis](https://github.com/arnaudbagnis)
- [All Contributors](https://github.com/multidimension-al/oauth2-shopify/contributors)

License
-------

[](#license)

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

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance43

Moderate activity, may be stable

Popularity35

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 97.3% 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 ~1495 days

Total

3

Last Release

447d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.5.0

v1.0.2PHP  &gt;=8.2 &lt;8.5.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6588235?v=4)[AJ Quick](/maintainers/ajquick)[@ajquick](https://github.com/ajquick)

---

Top Contributors

[![ajquick](https://avatars.githubusercontent.com/u/6588235?v=4)](https://github.com/ajquick "ajquick (36 commits)")[![tanigami](https://avatars.githubusercontent.com/u/86785?v=4)](https://github.com/tanigami "tanigami (1 commits)")

---

Tags

clientoauthoauth2authorizationshopify

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[league/oauth2-google

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

42121.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)[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)
