Get Order List Using Customer Token - Magento 2 Rest Api

Get Order List Using Customer Token - Magento 2 Rest Api

July 27, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Get Order List Using Customer Token - Magento 2 Rest Api

Accessing Order List via Magento 2 REST API: A Comprehensive Guide

If you’re attempting to retrieve order data using the Magento 2 REST API’s /V1/orders endpoint with a customer token as authorization, you may encounter the “Consumer is not authorized to access %resources” error message. This post will guide you through understanding and resolving this issue.

The Core Problem: Customer Token Permissions

The root cause of your problem lies in Magento 2’s default permission settings for REST API consumers (tokens). By design, customer tokens are restricted from accessing certain resources, including the sales orders (Magento_Sales::sales).

Steps to Get Order List Using a Customer Token

1. Understanding Required Permissions

To access order data via the REST API, you need the Magento_Sales::sales permission assigned to your token’s associated user role.

2. Assigning the Permission

Follow these steps in the Magento admin panel:

  • Navigate to Stores > Users.
  • Find and select the user associated with your customer token.
  • Click on Edit under the Actions column.
  • In the User Roles section, ensure that Magento_Sales::sales is assigned to the role linked to this user. If not, click Save Role Assignment at the bottom of the page.

3. Refreshing Your Token

After updating the permissions, you need a new token:

  • Go to Stores > Configuration.
  • Navigate to Advanced > Admin > Security under the Admin Panel section.
  • Click Generate New Access Key.
  • Copy and use this new token in your API requests.

Making the API Request with the Updated Token

Now, try making your request again using the updated customer token:

GET http://magento.local/index.php/rest/V1/orders?searchCriteria
Authorization: Bearer NEW_TOKEN_HERE

Replace NEW_TOKEN_HERE with your newly generated access key.

Verifying the Response

Upon successful execution, you should receive an XML or JSON response containing the order list:

{
  "items": [
    {
      "entity_id": 123,
      "state": "processing",
      "is_virtual": false,
      "grand_total": 97.04,
      "increment_id": "100000001"
    }
  ],
  "search_criteria": {},
  "total_count": 1
}

Conclusion

Retrieving order data via the Magento 2 REST API using a customer token requires assigning the necessary permissions to the associated user role. After refreshing your token, you can make successful API calls to fetch order lists.

Remember to always test your tokens in a development environment before deploying changes to production. Also, consider using an API testing tool like Postman or Insomnia for easier debugging and request/response analysis.

For more advanced Magento 2 REST API tutorials and best practices, visit Laravel Company’s Magento Development Blog.

Magento 2 Security API Admin

Our network