Skip to Content

OAuth 2.0 authorization

Get access tokens from the Authorization API with the client_credentials, authorization_code and refresh_token grants.

Every Marketplace API call needs an OAuth 2.0 access token. You get tokens from one operation, Create an access token:

POST https://marketplace.walmart.com/seller/v4/auth/token

In sandbox, use https://sandbox.marketplace.walmart.com/seller/v4/auth/token. Note that the Authorization API's server is .../seller, while every other API's server is .../seller/v1.

Choose a grant type

grant_typeWho uses itWhat you send
client_credentialsSellers calling the APIs for their own account (seller-direct)Client authentication
authorization_codeSolution Providers acting for a seller (delegated)code, plus PKCE code_verifier, or confidential-client authentication and redirect_uri
refresh_tokenSolution Providers renewing delegated accessrefresh_token; public clients also send client_id

The request body is always form-encoded (Content-Type: application/x-www-form-urlencoded) and the response is JSON.

Authenticate your client

A confidential client (one that can keep a Client Secret on a server) authenticates in one of two ways:

  • HTTP Basic: send Authorization: Basic <base64(client_id:client_secret)> and leave client_id and client_secret out of the body.
  • client_secret_post: send client_id and client_secret as form fields.

Use only one method. A request that combines HTTP Basic with credentials in the body returns 400 with invalid_request.

A public client (for example a desktop or mobile app) sends no client secret. Public clients that use the authorization_code grant must use PKCE.

Seller-direct access: client_credentials

Use this grant when you call the APIs for your own seller account.

curl -X POST "https://marketplace.walmart.com/seller/v4/auth/token" \
  -u "$WALMART_CLIENT_ID:$WALMART_CLIENT_SECRET" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Accept: application/json" \
  -H "x-o-tenant: WALMART_US" \
  -d "grant_type=client_credentials"

Or, with client_secret_post:

curl -X POST "https://marketplace.walmart.com/seller/v4/auth/token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Accept: application/json" \
  -d "grant_type=client_credentials" \
  -d "client_id=$WALMART_CLIENT_ID" \
  -d "client_secret=$WALMART_CLIENT_SECRET"

The client_credentials grant returns an access token without a refresh token. When the token expires, request a new one the same way. You can send scope, but it doesn't reduce the access provisioned for your client, and the response doesn't echo it. See API scopes.

Delegated access: authorization_code with PKCE

Solution Provider apps use this grant after a seller approves the app.

  1. Create a PKCE code_verifier: a random string of 43 to 128 characters from A-Z, a-z, 0-9, -, ., _ and ~.
  2. Derive the code_challenge from it with the S256 method. The plain method isn't accepted.
  3. Send the seller to Walmart Account Login at https://login.account.wal-mart.com/authorize with your code_challenge. To receive a refresh token, request the offline_access scope.
  4. After the seller approves, Walmart returns an authorization code to your app.
  5. Exchange the code for tokens:
curl -X POST "https://marketplace.walmart.com/seller/v4/auth/token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Accept: application/json" \
  -d "grant_type=authorization_code" \
  -d "code=$AUTHORIZATION_CODE" \
  -d "code_verifier=$CODE_VERIFIER" \
  -d "client_id=$WALMART_CLIENT_ID"

A public client must send code_verifier. A confidential client can omit code_verifier if it authenticates at the token operation and sends redirect_uri:

curl -X POST "https://marketplace.walmart.com/seller/v4/auth/token" \
  -u "$WALMART_CLIENT_ID:$WALMART_CLIENT_SECRET" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Accept: application/json" \
  -d "grant_type=authorization_code" \
  -d "code=$AUTHORIZATION_CODE" \
  -d "redirect_uri=https://app.example.com/walmart/callback"

PKCE is recommended for all clients, including confidential ones.

Renew delegated access: refresh_token

When offline_access was granted, the token response includes a refresh_token. Use it to get a new access token without asking the seller to sign in again:

curl -X POST "https://marketplace.walmart.com/seller/v4/auth/token" \
  -u "$WALMART_CLIENT_ID:$WALMART_CLIENT_SECRET" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Accept: application/json" \
  -d "grant_type=refresh_token" \
  -d "refresh_token=$REFRESH_TOKEN"

Public clients send client_id in the body instead of authenticating. If you send scope, it must not exceed the scope originally granted.

Token response

{
  "access_token": "<access_token>",
  "token_type": "Bearer",
  "expires_in": 900,
  "refresh_token": "<refresh_token>"
}
FieldAlways presentDescription
access_tokenYesOpaque Bearer access token.
token_typeYesAlways Bearer.
expires_inYesAccess token lifetime, in seconds.
refresh_tokenNoReturned for delegated authorization when offline_access was granted.
scopeNoSpace-delimited scopes granted for delegated authorization. Present when the delegated scope is narrowed from the original grant.

Optional fields are left out when they don't apply. They're never sent as null.

Select a market with x-o-tenant

The optional x-o-tenant header selects the market the token is issued for. Send exactly one value. Comma-separated values are rejected.

ValueMarket
WALMART_USWalmart US
WALMART_CAWalmart Canada
WALMART_MXWalmart Mexico
WALMART_CLWalmart Chile
  • A direct client that's active in more than one market must send x-o-tenant.
  • A direct client with exactly one active market uses that market when the header is left out.
  • For a delegated token, the market comes from the seller's authorization. If you send x-o-tenant, it must match.

Use the token

Send the access token on every Marketplace API request:

GET /v4/orders HTTP/1.1
Host: marketplace.walmart.com
Authorization: Bearer <access_token>
Accept: application/json

Don't use WM_SEC.ACCESS_TOKEN

The V4 APIs accept the access token only in the Authorization: Bearer header. Don't send it as WM_SEC.ACCESS_TOKEN.

Errors

Token errors return a JSON body with an error code, and may include error_description and error_uri:

{
  "error": "invalid_request",
  "error_description": "<description of the problem>"
}
StatusWhen it happens
400The token request is invalid. For example, combining HTTP Basic with credentials in the body returns invalid_request.
401Client authentication failed. The response includes a WWW-Authenticate header, for example Basic realm="seller-api".
429The request exceeded the applicable rate limit.
500An unexpected server error occurred. error is server_error.
502A service the token endpoint depends on is temporarily unavailable. error is temporarily_unavailable. Retry the request.

The error field is one of these codes:

errorWhat to check
invalid_requestA required parameter is missing, or the request is malformed.
invalid_clientYour Client ID or Client Secret.
invalid_grantThe authorization code, PKCE verifier or refresh token.
unauthorized_clientWhether your client may use this grant type.
unsupported_grant_typegrant_type is one of client_credentials, authorization_code or refresh_token.
invalid_scopeThe requested scope. On a refresh, it must not exceed the original grant.
MARKETPLACE_AMBIGUOUSThe market. If your client is active in more than one market, send x-o-tenant.
server_errorNothing on your side. Retry later.
temporarily_unavailableNothing on your side. Retry the request.

Best practices

  • Cache tokens. Reuse an access token until shortly before expires_in runs out, rather than requesting a new token for every call.
  • Keep secrets out of logs. Treat access tokens, refresh tokens and client secrets as sensitive values. Don't log them.
  • Store refresh tokens securely. A refresh token gives long-lived access to a seller's account.
  • Use one client authentication method per request.

On this page