PHPackages                             lulacanci/oauth2-walmart - 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. lulacanci/oauth2-walmart

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

lulacanci/oauth2-walmart
========================

Walmart Marketplace OAuth2 Client Provider for The PHP League OAuth2-Client

v1.0.4(2mo ago)035MITPHPPHP ^8.0

Since Jan 22Pushed 2mo agoCompare

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

READMEChangelogDependencies (12)Versions (6)Used By (0)

Walmart Marketplace Provider for OAuth 2.0 Client
=================================================

[](#walmart-marketplace-provider-for-oauth-20-client)

[![License](https://camo.githubusercontent.com/92887611d82cf8bce0209fac7e5af7b66700c2442bce2ba0fc593efa0949eac6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c756c6163616e63692f6f61757468322d77616c6d617274)](https://github.com/lulacanci/oauth2-walmart/blob/main/LICENSE)[![Latest Stable Version](https://camo.githubusercontent.com/bc4cbd956ed38581214a44acd596581023bbc98014bdc869026df13e238e2d69/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c756c6163616e63692f6f61757468322d77616c6d617274)](https://packagist.org/packages/lulacanci/oauth2-walmart)

This package provides [Walmart Marketplace](https://developer.walmart.com/) OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

This package is compliant with [PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md), [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) and [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md). If you notice compliance oversights, please send a patch via pull request.

Features
--------

[](#features)

- **Client Credentials Grant** - For sellers accessing their own Walmart Marketplace account
- **Authorization Code Grant** - For solution providers acting on behalf of sellers
- **Refresh Token Grant** - Automatically refresh expired access tokens
- **Multi-Marketplace Support** - US, Canada, and Mexico marketplaces

Requirements
------------

[](#requirements)

To use this package, you will need a Walmart client ID and client secret. These are referred to as `{walmart-client-id}` and `{walmart-client-secret}` in the documentation.

### For Sellers

[](#for-sellers)

Follow the [Get started as a seller](https://developer.walmart.com/us-marketplace/docs/get-started-as-a-seller) guide to create your API credentials.

### For Solution Providers

[](#for-solution-providers)

Follow the [Get started as a Solution Provider](https://developer.walmart.com/us-marketplace/docs/get-started-as-a-solution-provider) guide to register your application.

Installation
------------

[](#installation)

To install, use composer:

```
composer require lulacanci/oauth2-walmart
```

Usage
-----

[](#usage)

### Option 1: Client Credentials Grant (Sellers)

[](#option-1-client-credentials-grant-sellers)

Use this when your application is accessing your own Walmart seller account only.

```
require __DIR__ . '/vendor/autoload.php';

use Lulacanci\OAuth2\Client\Provider\Walmart;
use Lulacanci\OAuth2\Client\Provider\WalmartMarketplace;

$provider = new Walmart(
    [
        'clientId'     => '{walmart-client-id}',
        'clientSecret' => '{walmart-client-secret}',
    ],
    [],
    WalmartMarketplace::US // or CANADA, MEXICO
);

// Get access token using client credentials
$token = $provider->getAccessTokenWithClientCredentials();

echo 'Access Token: ' . $token->getToken() . "\n";
echo 'Expires in: ' . $token->getExpires() . " seconds\n";

// Use the token with Walmart APIs
// Include it in the WM_SEC.ACCESS_TOKEN header
```

### Option 2: Authorization Code Grant (Solution Providers)

[](#option-2-authorization-code-grant-solution-providers)

Use this when your application acts on behalf of other sellers. The seller must authorize your app first.

```
require __DIR__ . '/vendor/autoload.php';

use Lulacanci\OAuth2\Client\Provider\Walmart;
use Lulacanci\OAuth2\Client\Provider\WalmartMarketplace;

session_start();

$clientId = '{walmart-client-id}';
$clientSecret = '{walmart-client-secret}';
$redirectUri = 'https://example.com/callback-url';

$provider = new Walmart(
    [
        'clientId'     => $clientId,
        'clientSecret' => $clientSecret,
        'redirectUri'  => $redirectUri,
    ],
    [],
    WalmartMarketplace::US
);

if (empty($_GET['code'])) {
    // Step 1: Redirect to Walmart authorization URL
    // The seller will be prompted to log in and authorize your app

    $authorizationUrl = $provider->getAuthorizationUrl();
    $_SESSION['oauth2state'] = $provider->getState();

    header('Location: ' . $authorizationUrl);
    exit;

} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
    // State is invalid, possible CSRF attack in progress
    unset($_SESSION['oauth2state']);
    exit('Invalid state');

} else {
    // Step 2: Exchange authorization code for access token + refresh token

    $token = $provider->getAccessToken('authorization_code', [
        'code' => $_GET['code'],
        'redirect_uri' => $redirectUri,
    ]);

    // Store these tokens securely!
    $accessToken = $token->getToken();           // Valid for 15 minutes
    $refreshToken = $token->getRefreshToken();   // Valid for 1 year

    echo 'Access Token: ' . $accessToken . "\n";
    echo 'Refresh Token: ' . $refreshToken . "\n";
}
```

### Option 3: Refresh Token Grant

[](#option-3-refresh-token-grant)

Access tokens expire after 15 minutes. Use the refresh token to get a new access token without requiring user interaction. Refresh tokens are valid for 1 year.

```
require __DIR__ . '/vendor/autoload.php';

use Lulacanci\OAuth2\Client\Provider\Walmart;
use Lulacanci\OAuth2\Client\Provider\WalmartMarketplace;

$provider = new Walmart([
        'clientId'     => '{walmart-client-id}',
        'clientSecret' => '{walmart-client-secret}',
        'redirectUri'  => 'https://example.com/callback-url',
    ],
    [],
    WalmartMarketplace::US
);

// Use your stored refresh token
$storedRefreshToken = 'your-stored-refresh-token';

$newToken = $provider->getAccessToken('refresh_token', [
    'refresh_token' => $storedRefreshToken,
]);

$accessToken = $newToken->getToken();
// Store the new access token securely
```

Multi-Marketplace Support
-------------------------

[](#multi-marketplace-support)

The package supports all Walmart marketplaces:

```
use Lulacanci\OAuth2\Client\Provider\WalmartMarketplace;

// US Marketplace (default)
$provider = new Walmart($options, [], WalmartMarketplace::US);
// Sets clientType=seller

// Canada Marketplace
$provider = new Walmart($options, [], WalmartMarketplace::CANADA);
// Sets clientType=seller-ca

// Mexico Marketplace
$provider = new Walmart($options, [], WalmartMarketplace::MEXICO);
// Sets clientType=seller-mx
```

Using the Access Token with Walmart APIs
----------------------------------------

[](#using-the-access-token-with-walmart-apis)

Include the access token in the `WM_SEC.ACCESS_TOKEN` header for all Walmart Marketplace API calls:

```
$client = new GuzzleHttp\Client();

$response = $client->get('https://marketplace.walmartapis.com/v3/items', [
    'headers' => [
        'WM_SEC.ACCESS_TOKEN' => $token->getToken(),
        'WM_SVC.NAME' => 'Walmart Marketplace',
        'WM_QOS.CORRELATION_ID' => uniqid(),
        'Accept' => 'application/json',
    ],
]);
```

Scopes
------

[](#scopes)

[Scopes](https://developer.walmart.com/us-marketplace/docs/api-scope-walmart-marketplace) can be set by using the `scope` parameter when generating the authorization URL:

```
$authorizationUrl = $provider->getAuthorizationUrl([
    'scope' => ['items', 'orders', 'inventory'],
]);
```

See the [API scopes documentation](https://developer.walmart.com/us-marketplace/docs/api-scope-walmart-marketplace) for available scopes.

Testing
-------

[](#testing)

Tests can be run with:

```
./vendor/bin/phpunit
```

Or with the watcher:

```
composer test
```

Documentation
-------------

[](#documentation)

- [Walmart OAuth 2.0 Authorization](https://developer.walmart.com/us-marketplace/docs/oauth-20-authorization)
- [Get an Access Token](https://developer.walmart.com/us-marketplace/docs/get-an-access-token)
- [Log in and Authorize App Scope](https://developer.walmart.com/us-marketplace/docs/log-in-and-authorize-app-scope)
- [API Scopes for Walmart Marketplace](https://developer.walmart.com/us-marketplace/docs/api-scope-walmart-marketplace)

Credits
-------

[](#credits)

- [Iulian Danaila](https://github.com/lulacanci)
- [All Contributors](https://github.com/lulacanci/oauth2-walmart/contributors)

Sponsors
--------

[](#sponsors)

[Aureus POS - The Gold Standard Of Bullion &amp; Collectibles Software](https://www.aureuspos.com/)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/lulacanci/oauth2-walmart/blob/main/LICENSE) for more information.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance88

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 73.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 ~12 days

Total

5

Last Release

62d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/833e3df6fd364411bf6903c189bc6f50d2787883c18b7c403007adf99126863e?d=identicon)[lulacanci](/maintainers/lulacanci)

---

Top Contributors

[![lulacanci](https://avatars.githubusercontent.com/u/21103435?v=4)](https://github.com/lulacanci "lulacanci (11 commits)")[![acip](https://avatars.githubusercontent.com/u/1649442?v=4)](https://github.com/acip "acip (4 commits)")

---

Tags

clientoauthoauth2walmartmarketplaceseller

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/lulacanci-oauth2-walmart/health.svg)

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

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