Admin Token: Fast Access for a First Result
Admin Token: Fast Access for a First Result
~11 Min. Lesezeit Zuletzt aktualisiert am August 8, 2026
Time for your FIRST real result: a valid access token and your actual Magento products as JSON – all BEFORE a single line of React code, via curl in the terminal.
Requesting a token via admin login
POST /V1/integration/admin/token takes an existing Magento admin account's username and password and, on success, returns an access token:
curl -s -X POST https://YOUR-SHOP.com/rest/V1/integration/admin/token \
-H "Content-Type: application/json" \
-d '{"username": "YOUR_ADMIN_USERNAME", "password": "YOUR_ADMIN_PASSWORD"}'The response is a single, quoted JSON string – EXACTLY that string (without the outer quotes) is your token:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."Achtung: For security reasons, NEVER write your real admin password into a file that could accidentally get committed – for this one-off test call in the terminal it's harmless, in chapter 6 we'll set up SECURE storage for ongoing use.
Using the token for a real product request
With the token attached as a bearer token in the Authorization header, GET /V1/products returns your real product data:
TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
curl -s https://YOUR-SHOP.com/rest/V1/products?searchCriteria%5BpageSize%5D=2 \
-H "Authorization: Bearer $TOKEN" | python3 -m json.toolsearchCriteria%5BpageSize%5D=2 is the URL-encoded form of searchCriteria[pageSize]=2 (square brackets must be encoded in URLs) and limits the response to 2 products for this test – more on searchCriteria in chapter 8.
The response structure at a glance
A GET /V1/products response ALWAYS has the same basic shape, regardless of how many products come back:
{
"items": [ { "sku": "...", "name": "...", "price": 19.99, ... }, ... ],
"search_criteria": { ... },
"total_count": 247
}items is the array of actual products, total_count is the TOTAL number of matching products (independent of pageSize) – important for pagination in chapter 8. We'll examine a single product object in detail in chapter 10, once we build the detail page.
Tipp: Did this curl call work for you? Then you just successfully communicated with REAL data from YOUR shop – everything else in this tutorial is "just" React code wrapped around it. If you got an error instead, first check that the username/password are correct and that the admin account isn't locked.
A note for shops with two-factor authentication enabled
Achtung: If two-factor authentication (2FA) is enabled for the admin area in the Magento admin panel, POST /V1/integration/admin/token with plain username/password may fail, since 2FA needs separate configuration for this API endpoint. For this learning project, it's best to either disable 2FA on a local test instance, or move straight to the integration token from chapter 5, which doesn't have this problem.