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

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

chadhutchins/oauth2-shopify
===========================

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

v1.0.6(6y ago)21.7k↓100%MITPHPPHP &gt;=5.5.0

Since Dec 21Pushed 6y ago1 watchersCompare

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

READMEChangelog (5)Dependencies (4)Versions (8)Used By (0)

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

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

[![Latest Stable Version](https://camo.githubusercontent.com/c6e0a0bdd070b20103b31f001e7984d3f18166f24c2202e89f361195adfaa2ff/68747470733a2f2f706f7365722e707567782e6f72672f636861646875746368696e732f6f61757468322d73686f706966792f762f737461626c65)](https://packagist.org/packages/chadhutchins/oauth2-shopify)[![Total Downloads](https://camo.githubusercontent.com/d497b451bc96ab13c6eb7238e49b2a667d7310b327942afc256f0a7bad25e3c5/68747470733a2f2f706f7365722e707567782e6f72672f636861646875746368696e732f6f61757468322d73686f706966792f646f776e6c6f616473)](https://packagist.org/packages/chadhutchins/oauth2-shopify)[![License](https://camo.githubusercontent.com/2206bc931f470d19f73db124c1b9f53a09705e3c98fb6f98771e12dd1b515d8b/68747470733a2f2f706f7365722e707567782e6f72672f636861646875746368696e732f6f61757468322d73686f706966792f6c6963656e7365)](https://packagist.org/packages/chadhutchins/oauth2-shopify)[![Build Status](https://camo.githubusercontent.com/5a9b9b5a1b0ed7af538360069c4123f1ff43ff5d998e8a58152370288d310971/68747470733a2f2f7472617669732d63692e6f72672f6d756c746964696d656e73696f6e2d616c2f6f61757468322d73686f706966792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/multidimension-al/oauth2-shopify)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/40c4a7f9ba6da98d21d4bb30ee2473f523b43d9e645b23b7d20f84c3bd13d057/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d756c746964696d656e73696f6e2d616c2f6f61757468322d73686f706966792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/multidimension-al/oauth2-shopify/?branch=master)

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 chadhutchins/oauth2-shopify

```

### Usage

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new Chadhutchins\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)

```
$ ./vendor/bin/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)
- [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

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 71.4% 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 ~174 days

Recently: every ~0 days

Total

7

Last Release

2387d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c22d34631d930cec68e9073570d01ee28e6afd23e19046ab936b3612d9304125?d=identicon)[chadhutchins](/maintainers/chadhutchins)

---

Top Contributors

[![ajquick](https://avatars.githubusercontent.com/u/6588235?v=4)](https://github.com/ajquick "ajquick (20 commits)")[![chadhutchins](https://avatars.githubusercontent.com/u/47898?v=4)](https://github.com/chadhutchins "chadhutchins (7 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/chadhutchins-oauth2-shopify/health.svg)

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

###  Alternatives

[league/oauth2-google

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

41721.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)
