Magento 2 Rest API Authentication
Magento 2 Rest API Authentication
Magento 2 Rest API Authentication
Magento 2 Rest API
Three types of API Authentication.
- Token based authentication
- OAUTH based authentication
- Session Based Authentication
1.Token based authentication
Customer token : Base_Url/V1/integration/customer/token
Method Type: POST
Hit url by POSTMAN
Body payload : raw
{
“username”:”test”,
“password”:”test”
}
——————————-
Admin Token : /V1/integration/admin/token
Method Type: POST
Hit url by POSTMAN
Body payload : raw
{
“username”:”test”,
“password”:”test”
}
——————————–
For Self
<route url=”/V1/customers” method=”GET”>
<service class=”Vendor\Module\Api\CustomerManagementInterface” method=”getCustomerList”/>
<resources>
<resource ref=”self”/>
</resources>
<data>
<parameter name=”customer_id” force=”true”>%customer_id%</parameter>
</data>
</route>
For anonymous
<route url=”/V1/products” method=”GET”>
<service class=”Venodor\Module\Api\ProductRepositoryInterface” method=”listProducts”/>
<resources>
<resource ref=”anonymous”/>
</resources>
</route>
For admin authorized
<route url=”/V1/products” method=”GET”>
<service class=”Venodor\Module\Api\ProductRepositoryInterface” method=”listProducts”/>
<resources>
<resource ref=”Vendor_Module::name”/>
</resources>
</route>
2.OAUTH based authentication
Adobe Commerce and Magento Open Source is based on OAuth 1.0a
System > Extensions > Integrations
Add New Integration.
3.Session Based Authentication
with anonymous or self permission in the webapi.xml configuration file
GET /rest/V1/customers/me
Magento_Customer::group API