Getting Started:
Magento has established itself as the leading platform for building robust and scalable online stores in the world of e-commerce. Magento provides online merchants with the tools they need to succeed in the digital marketplace with its extensive set of features and flexibility. One of the key aspects of Magento is its OAuth 1.0 Authentication Protocol, which helps ensure that different applications communicate with each other in a secure manner. In this blog post, we will use Postman, a popular API testing and development tool, to explore how to connect Magento 2 OAuth 1.0.
OAuth 1.0 Understanding:
OAuth (Open Authorization) is an open standard protocol. It provides secure and delegated access to protected resources. It allows users to grant third-party applications limited access to their resources without sharing their credentials. OAuth 1.0 uses a signature-based method to authenticate requests and is the predecessor to OAuth 2.0.
Magento 2 OAuth 1.0 setup:
To get started, you’ll need a running Magento 2 installation. Here are the steps to set up Magento 2 OAuth 1.0:
- Create a new consumer: In your Magento admin panel, navigate to
"System" → "Extensions" → "Integrations"
. Click on"Add New Integration"
and provide the necessary details such as the integration name, callback URL and permissions.
- Generate OAuth credentials: Once the integration is created, Magento 2 will generate the OAuth credentials, including the consumer key and secret. Make sure you store these credentials securely.
Postman Configuration:
Postman simplifies the process of developing and testing APIs. To configure Postman for Magento OAuth 1.0, follow these steps
- Install and run Postman: Download and install Postman on your system. Launch the application to continue.
- Create a new request: Click on the
'New'
button in the Postman interface to create new'HTTP Request'
.
- Set up the OAuth 1.0 authorisation:
- Enter the request URL: Enter the endpoint URL of the Magento API you wish to interact with.
- In the
'Authorisation'
tab, select'OAuth 1.0'
as the type. - Enter the Magento OAuth 1.0 credentials you have previously obtained:
Consumer key, Consumer secret, Access token and Token Secret
.
- Submit the request: Click the Send button to execute the request. Postman will automatically handle the OAuth 1.0 signature generation and authentication process.
API Reference
Get Product by sku
GET /rest/V1/products/{{sku}}
Parameter | Type | Description |
---|---|---|
{{sku}} | string | Product sku |
Get Customer by id
GET /rest/V1/customers/{{customer_id}}
Parameter | Type | Description |
---|---|---|
{{customer_id}} | int | Customer ID |
Get Order by id
GET /rest/V1/orders/{{order_id}}
Parameter | Type | Description |
---|---|---|
{{order_id}} | int | Order ID |
For more detailed information on additional API endpoints, you can refer to the Magento documentation using the link below: https://developer.adobe.com/commerce/webapi/rest/quick-reference/