How to work with Magento oAuth API

 

  • Enable Web API:

Store >> Configuration >> Services >> Magento Web API >> 

Allow Anonymous Guest Access : No

Allow OAuth Access Tokens to be used as standalone Bearer tokens: Yes

  • Get Token:

URL: http://server/rest/V1/integration/admin/token
Method: POST
Body:

{
"username": "user",
"password": "123",
"device": " "
}
Response: token as text, need to remove double quote in response
  • Get Orders:

URL: http://server/rest/V1/orders?search

Method: GET

Auth Type: Bearer Token

Param:

searchCriteria[filterGroups][0][filters][0][condition_type]=from&searchCriteria[filterGroups][0][filters][0][field]=updated_at&searchCriteria[filterGroups][0][filters][0][value]=2024-1-04 10:00:00&searchCriteria[page_size]=100&searchCriteria[currentPage]=1

  • Get Items:

URL: http://server/rest/V1/products

Method: GET
Param: searchCriteria[page_size]=70&searchCriteria[currentPage]=2
Auth Type: Bearer Token

  • Get an item by sku:

UR: http://server/rest/V1/products/{sku}

  • Get customers:

URL: http://server/rest/V1/customers/search

Params:  searchCriteria[filterGroups][0][filters][0][condition_type]=from&searchCriteria[filterGroups][0][filters][0][field]=updated_at&searchCriteria[filterGroups][0][filters][0][value]=2024-1-04 10:00:00&searchCriteria[page_size]=100&searchCriteria[currentPage]=1

Back to blog