Legacy Knowledge Base
Publicado Jun. 25, 2030

Unable to access product specifications via guest user

Written By

Pooja Bhambani

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • Users need to access product details via a headless admin API but through guest users (unauthenticated requests). However, users could use 'Service Access Policies' for this; though, even after adding the relevant classes in SAP, a view permissions error occurs.

  • Steps to reproduce:
    1. Start 2024.Q1.2.
    2. Create a website using a minium site template.
    3. Access localhost:8080/o/api.
    4. Select Rest Application as headless-commerce-admin-catalog/v1.0/
    5. Navigate to Product Specification and enter the product ID in the GET request of 'getProductIdProductsSpecificationsPage'.
    6. Response 200 was received with the response body.
    7. Now, navigate to Service Access Policies and create a new one, and paste the following classes:

    com.liferay.commerce.product.model.CommerceCatalog*
    com.liferay.commerce.product.service.CommerceCatalogService*
    com.liferay.headless.commerce.admin.catalog.internal.resource.v1_0.AttachmentResourceImpl*
    com.liferay.headless.commerce.admin.catalog.internal.resource.v1_0.ChannelResourceImpl*;
    com.liferay.headless.commerce.admin.catalog.internal.resource.v1_0.ProductResourceImpl*
    com.liferay.headless.commerce.delivery.catalog.internal.resource.v1_0.AttachmentResourceImpl*
    com.liferay.headless.commerce.delivery.catalog.internal.resource.v1_0.ChannelResourceImpl#getChannelsPage
    com.liferay.headless.commerce.delivery.catalog.internal.resource.v1_0.MappedProductResourceImpl#getChannelProductMappedProductsPage
    com.liferay.headless.commerce.delivery.catalog.internal.resource.v1_0.PinResourceImpl#getChannelProductPinsPage
    com.liferay.headless.commerce.delivery.catalog.internal.resource.v1_0.ProductResourceImpl#getChannelProduct

    8. Now, copy the ‘Request URL' that we’ve received after performing step 5 and paste it into the next tab.
    9. The following response was received on the UI page:

    {
    "status" : "NOT_FOUND",
    "title" : "User 20095 must have VIEW permission for com.liferay.commerce.product.model.CommerceCatalog 32038"
    }


    Expected Behavior: Guest users must be able to see the product specification by making unauthenticated requests.
    Actual Behavior: Guest users are unable to view the product specification by making unauthenticated requests.

Environment

  • 2024.Q1

Resolution

  • Headless Admin API is not meant for guest users, even with the Service Access Policy enabled.
  • However, if guest users need to see the specifications, delivery API could be used instead: /channels/{channelId}/products/{productId}/product-specificationsdefined on the product from the channel.
Did this article resolve your issue ?

Legacy Knowledge Base