1

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

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>

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.