1

I've created REST API in Magento2 but everyone can use it. How can I add basic auth to my API?

1 Answer 1

1

You need to add: <resource ref="anonymous" />

For example:

vendor/magento/module-search/etc/webapi.xml

<route url="/V1/search" method="GET">
    <service class="Magento\Search\Api\SearchInterface" method="search"/>
    <resources>
        <resource ref="anonymous" />
    </resources>
</route>
5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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