Overview
In this guide, you’ll learn how to use the Shopware 6 API with Postman and authenticate using the Shopware Admin API. We’ll explore three methods of authentication: Username and Password, Integration, and Refresh Token, and show how to use the access token to interact with the Shopware Store API via Postman.
Authentication API
The Shopware 6 API supports three authentication methods:
1. Username and Password (Password Grant Type)
2. Integration (Client Credentials Grant Type)
3. Refresh Token
1. Username and Password (Password Grant Type)
- In this grant, the type will be executed using the Shopware admin username and password
- Steps for executing api in Postman Â
In Postman create a post URL with /api/oauth/token
Method: POST
Post URL : {APP_URL}/api/oauth/token
Parameters :
Accept: application/json
Content-Type: application/json
Body: pass raw data in the body
{
“client_id”: “administration”,
“grant_type”: “password”,
“scopes”: “write”,
“username”: “your_admin_username”,
“password”: “your_admin_password”
}
It will return a response like :
{
“token_type”: “Bearer”,
“expires_in”: 600,
“access_token”: “access_token”,
“refresh_token”: “refresh_token”
}
2. Integration (Client Credentials Grant Type)
Steps for executing api in Postman
Go to settings > integration
Generate api key and secret
In Postman create a post URL with /api/oauth/token
Method: POST
Post URL : {APP_URL}/api/oauth/token
Parameters :
Accept: application/json
Content-Type: application/json
Body: pass raw data in the body
{
“grant_type”: “client_credentials”,
“client_id”: “<client-id>”,
“client_secret”: “<client-secret>”
}
It will return a response like this:
{
“token_type”: “Bearer”,
“expires_in”: 600,
“access_token”: “access_token”
}
3. Refresh Token
To use this grant type, you must obtain an access token that remains valid for 10 minutes. To proceed, you must set up an integration and acquire an Access Key ID and a Secret Access Key.
In Postman create a post URL with /api/oauth/token
Method: POST
Post URL : {APP_URL}/api/oauth/token
Parameters :
Accept: application/json
Content-Type: application/json
Body: pass raw data in the body
{
“grant_type”: “refresh_token”,
“client_id”: “<client-id>”,
“refresh_token”: “<refresh-token>”
}
It will return a response like :
{
“token_type”: “Bearer”,
“expires_in”: 600,
“access_token”: “access-token”,
“refresh_token”: “refresh-token”
}
Using the authorization bearer token, we can use this access token to access all admin for Shopware 6 api.
Get Category All Data from Shopware
In Postman create a post URL with /api/oauth/token
Method: POST
GET URL : {APP_URL}/api/category
Parameters :
Authorization: add an access token here which gets from Authorization.
Accept: application/json
Content-Type: application/json
The Shopware 6 API provides various methods for authentication, allowing you to interact with your Shopware store using Postman API. By following the steps outlined for Password Grant Type, Client Credentials Grant Type, and Refresh Token, you can efficiently manage and access data through the Shopware Admin API.