Kaskus

Tech

VadimFrost1Avatar border
TS
VadimFrost1
How to Generate a Full Swagger Documentation for Magento 2 REST API?
How to Generate a Full Swagger Documentation for Magento 2 REST API?
There are three user types that have access to the Magento 2 Swagger API:
1) Guest user;
2) Customer;
3) Administrator.
Guest and Customer users have anonymous and self permissions access. To be able to use all possibilities of Magento 2 Swagger, you need to generate an authentication API key. There are 2 options for how you can do it.
1. You need to create a new integration in your Magento 2 backend.
Step 1. Log in to the Admin Panel.
Step 2. Go to Systems >Extensions>Integrations.
Step 3. Click on the Add New Integration button.
Step 4. In the Integration Info tab, fill in
• Name: SomeUniqueIntegrationName;
• Email: example@mail.com;
• Callback URL: http://your_app_host/endpoint.php;
• Identity link URL: http://your_app_host/login.php;
• Your Password.
Step 5. Then go to the API tab and select All or Custom resource access, depending on the functionality you want to make available for the user.
Step 6. Save the changes.
Step 7. On the Integrations grid, click on Authorize
Step 8. Copy generated Access Token.
Step 9. Now you need to go to Magento 2 Swagger via http://your_app_host/swagger and apply this token.
It was the OAuth-based authentication. If you get an error, check the code meaning in the official Magento documentation. Let’s consider token-based authentication.
2. Another way to generate an admin-level access key is by using the curl:
curl -XPOST -H 'Content-Type: application/json' http://magento-url/rest/V1/integration/admin/token -d '{ "username": "user-name", "password": "admin-password" }'
You will receive a token like `bnkte0ubwd1n3gbyfst29pq0hg1vku0t` in response.
After filling the API key on Magento 2 Swagger page, click on apply, and you will get the full list of documentation.
3. And the third option is session-based authentication.
In this case, the Magento web API framework uses your logged-in session information to verify your identity and authorize access to the requested resource. If you log in as a customer, you only have anonymous or self permission access. The configurations are in the webapi.xml file.

Now you can use one of these methods to see the full list of Magento REST API documentation in Swagger.
Diubah oleh VadimFrost1 03-12-2019 16:50
0
261
0
GuestAvatar border
Komentar yang asik ya
GuestAvatar border
Komentar yang asik ya
Komunitas Pilihan