1

I am building a mobile application for a Magento instance. I can use Token Based Authentication to make the API calls. However I want to enable guest access in my app. The users should be able to browse the categories and products and add to card without signing in, and only need to sign in when they are checking out. Is this possible?

2
  • Did you able to manage guest user browsing ? Jun 22 '17 at 6:24
  • Did the answer below help you? Anything to report?
    – jamil
    Mar 14 '18 at 0:37
1

I think you can use the anonymous resource for your api method, like:

<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
    <route url="/V1/path/to/method" method="POST">
        <service class="Vendor\Module\Api\OwnInterface" method="methodName"/>
        <resources>
            <resource ref="anonymous" />
        </resources>
    </route>
</routes>

Because:

Use the token in a Web API request

Any web API call that accesses a resource that requires a permission level higher than anonymous must contain the authentication token in the header To do this, specify a HTTP header in the following format:

Authorization: Bearer

Source: Token-based authentication

You can find example here: magento/module-quote/etc/webapi.xml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.