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

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

cargix1/oauth2-shopify
======================

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

031PHP

Since Sep 9Pushed 10y ago1 watchersCompare

[ Source](https://github.com/cargix1/oauth2-shopify)[ Packagist](https://packagist.org/packages/cargix1/oauth2-shopify)[ RSS](/packages/cargix1-oauth2-shopify/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Shopify Provider for OAuth 2.0 Client - WORK IN PROGRESS
========================================================

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

This package provides Shopify 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 cargx1/oauth2-shopify

```

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

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

if (!isset($_GET['code'])) {

    // If we don't have an authorization code then get one
    $authUrl = $provider->getAuthorizationUrl();
    $_SESSION['oauth2state'] = $provider->state;
    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
        $userDetails = $provider->getUserDetails($token);

        // Use these details to create a new profile
        printf('Hello %s!', $userDetails->firstName);

    } catch (Exception $e) {

        // Failed to get user details
        exit('Oh dear...');
    }

    // Use this to interact with an API on the users behalf
    echo $token->accessToken;
}
```

###  Health Score

20

—

LowBetter than 16% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

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/68790c68bb0a19612851df0d4678fbaca22a19b8f7a925cde2f754140f4fca92?d=identicon)[cargi](/maintainers/cargi)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[league/oauth2-client

OAuth 2.0 Client Library

3.8k115.1M1.0k](/packages/league-oauth2-client)[google/auth

Google Auth Library for PHP

1.4k266.3M128](/packages/google-auth)[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k98.4M89](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99895.6M97](/packages/league-oauth1-client)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70316.0M32](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

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

41720.5M102](/packages/league-oauth2-google)

PHPackages © 2026

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