Change Magento 2.1 guest permissions to access web api catalog/products

Change Magento 2.1 guest permissions to access web api catalog/products

October 3, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Change Magento 2.1 guest permissions to access web api catalog/products

Changing Guest Permissions for Magento API Access

As a developer new to Magento, you’re likely looking for ways to simplify your workflows. One common task is retrieving product data from the Magento API without requiring authentication. However, making this change correctly requires some understanding of how Magento handles permissions.

Understanding Magento’s REST API Permissions

Magento uses a role-based permission system to control access to its REST APIs. The Guest role, which corresponds to anonymous users, has limited access by default. This is primarily designed for security reasons, as it prevents unauthorized parties from accessing sensitive data.

When you try to access the /V1/products endpoint with your current setup, Magento throws a “Consumer not authorized” error because the Guest role doesn’t have permission to view product information.

The Common Approach and Its Limitations

You’re correct in identifying that editing the webapi.xml file directly is a bit hacky. This approach involves hardcoding permissions into the core Magento files, which can lead to issues during updates or if another developer needs to adjust the settings later on.

Moreover, changing permissions this way doesn’t scale well. If you need to add more endpoints or roles in the future, editing the core XML file can become quite complex and error-prone.

A Better Approach: Using ACLs

Instead of modifying the core configuration, we’ll use Magento’s Access Control List (ACL) system. ACLs allow you to define permissions dynamically, making your changes more portable and maintainable.

Step 1: Identify the Resource

The first step is to identify the resource that corresponds to the products endpoint. In this case, it’s Magento_Catalog::products. This tells Magento which module and specific resource we’re granting access to.

Step 2: Create a New ACL Entry

We’ll create a new ACL entry for the Guest role. This entry will grant full access to the products resource.

<acl>
    <resources>
        <all>
            <children>
                <Magento_Catalog::product>
                    <children>
                        <index>
                            <children>
                                <list>
                                    <title>Products</title>
                                    <children>
                                        <Guest::all_products>
                                            <title>View All Products</title>
                                            <resource>Magento_Catalog::products</resource>
                                            <sortorder>1000</sortorder>
                                            <action_id>index</action_id>
                                            <available>
                                                <customer_group>Not Logged In</customer_group>
                                                <group_id>3</group_id>
                                                <allow_all>1</allow_all>
                                            </available>
                                        </Guest::all_products>
                                    </children>
                                </list>
                            </children>
                        </index>
                    </children>
                </Magento_Catalog::product>
            </children>
        </all>
    </resources>
</acl>

Step 3: Add the ACL Entry to Your Theme

To apply this change, you’ll need to add this XML snippet to your theme’s webapi.xml file or create a new one in your custom module.

Note that adding an entry for Guest access should be done with caution. It’s generally recommended only if you have a specific use case where security is not a primary concern.

Retrieving Products via the API

Once the ACL change has been made and Magento’s cache has been cleared, you can retrieve all products using this endpoint:

http://magento.dev/rest/V1/products

The response will now contain an array of product objects in JSON format:

{
  "items": [
    {
      "id": 1,
      "sku": "24-MB01",
      "name": "T-Shirt (Blue)",
      "attribute_set_id": 9,
      "type_id": "simple",
      "created_at": "2015-07-16 03:28:49.000000+00:00",
      "updated_at": "2017-02-22 04:00:25.000000+00:00",
      "category_ids": [3],
      "price": 98,
      "tax_class_id": 4,
      "visibility": 4,
      "status": 1
    },
    // More products...
  ],
  "total_count": 27
}

Conclusion

While Magento’s default permissions can be restrictive at first, the Access Control List system provides a powerful and flexible way to manage API access. By creating a new ACL entry for the Guest role, you’ve opened up access to the products resource without resorting to hardcoding changes in core files.

Remember that changing guest permissions should be done judiciously, as it can potentially expose sensitive data if not properly secured.

For more information on Magento’s REST APIs and best practices for API development, I recommend checking out our comprehensive guide at LaravelCompany.

Magento 2 Catalog Security API

Our network