How to create Admin token Rest API in Magento 2 Programmatically?

  • Admin Token REST API Magento 2.

Magento 2 Admin Token REST API, you need to first generate an access token. The access token used for synchronization with Magento to another third-party platform.

Without an Access token, you can’t communicate with Magento 2. For Create access token you need to call POST action with Request payload. Your request URL will be rest/V1/integration/admin/token append to your site URL.

Pass the username and password in the request body of Magento backend to generate the Access token.

After successfully call with Magento 2, You can get a response as a string with Access Token. You can use access token with any Magento 2 REST API call with “Bearer {$accessToken}

Output:
qhkk60btde5681tfvvhd921sw2051t02

You can use the token in a Web API request as below,
Authorization: Bearer <access token>
Where Replace <access token> token with your actual access token.

PostMan Screen to generate Admin Token for the Magento 2,

Admin token REST API
Admin token REST API