{"id":2512,"date":"2024-12-31T20:22:33","date_gmt":"2024-12-31T20:22:33","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/magento-2-api-get-admin-token\/"},"modified":"2025-04-24T09:38:57","modified_gmt":"2025-04-24T04:08:57","slug":"magento-2-api-get-admin-token","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/magento-2-api-get-admin-token\/","title":{"rendered":"Magento 2 API &#8211; Get Admin Token"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hello, Magento peeps!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In my last blog post I had covered everything you need to know about Magento 2 API while developing a custom app. In case you missed reading it, you can read it at:&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/magento-2-api\/\" target=\"_blank\" rel=\"noreferrer noopener\">What is Magento 2 API &amp; You can Use it?<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this blog post I will guide you through&nbsp;Magento 2 API \u2013 Get Admin Token.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Magento 2 allows the developers to access the platform through its APIs. Magento 2 APIs are powerful and allow different levels of access to the guest users, customers, and admin users. The admin users may require to pass the admin token to perform any admin-level activities through the APIs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In order to access the Magento 2 admin panel through APIs, you may require to first get an admin token. Here is the complete tutorial to get admin token through API in Magento 2.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Get Admin Token Using Magento 2 API?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The admin token in Magento 2 verifies that the call is authentic to access the system resources and perform certain actions.&nbsp;To get an admin token in Magento 2, the client sends the admin user\u2019s username and password to verify the identity through an API call.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Generally, the admin token in Magento 2 is valid for four hours. It can be changed from&nbsp;<strong>Stores &gt; Settings &gt; Configuration &gt; Services &gt; OAuth &gt; Access Token Expiration &gt; Admin Token Lifetime (hours)<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Provided below is the complete API call to get admin token in Magento 2.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Method:&nbsp;<\/strong>Post<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>URL:&nbsp;<\/strong><em>store_url\/rest\/V1\/integration\/admin\/token<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Headers:&nbsp;<\/strong><em>Content-Type: application\/json<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Body:<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n  \"username\": \"your-username\",\n  \"password\": \"your-password\"\n}<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/04\/Magento-2-API-Get-Admin-Token-700x407-1.png\" alt=\"Magento 2 API Get Admin Token 700x407\" class=\"wp-image-50128\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Response:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>5r8cvmpr11j6gmau8990rcj2qk7unh8i<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is how you can get admin token in Magento 2 through API. This admin token can be used in the header of every API call that requires admin access.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Magento 2 admin token is essential to access the API resource. The token is essential to make API calls that require admin access in Magento 2. I hope this tutorial will help you to get admin token in Magento 2 through REST API.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In case you still have any queries or doubts regarding it, feel free to comment. I would be happy to help you. \ud83d\udcab<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, do not forget to share this Magento 2 API tutorial with your developer friends through social media! \ud83d\udd17<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks for reading. \ud83d\ude0a<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello, Magento peeps! In my last blog post I had covered everything you need to know about Magento 2 API while developing a custom app&#8230;.<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-2512","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2512","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=2512"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2512\/revisions"}],"predecessor-version":[{"id":12869,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2512\/revisions\/12869"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=2512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=2512"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=2512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}