{"id":2566,"date":"2024-12-31T20:23:00","date_gmt":"2024-12-31T20:23:00","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/magento-2-api-get-customer-token\/"},"modified":"2025-07-16T14:55:06","modified_gmt":"2025-07-16T09:25:06","slug":"magento-2-api-get-customer-token","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/magento-2-api-get-customer-token\/","title":{"rendered":"Magento 2 API &#8211; Get Customer Token"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hello, Magento peeps!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Magento 2\u00a0is amazing, and so does its API. In my last post, I talked about creating a new customer account using\u00a0<a href=\"https:\/\/meetanshi.com\/blog\/magento-2-api\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 API<\/a>. In this post, I will show how you can get a customer token to perform customer log in using API.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Customer login is a must-have functionality for eCommerce stores. If you are developing a third-party app or mobile app on Magento 2, you can use the Magento 2 API to allow the customers to log in using their credentials on the applications. Magento 2 provides a customer token to allow the users to perform specific functions that require customer-level access. In this blog post, I have explained the&nbsp;Magento 2 API \u2013 Get Customer Token&nbsp;in detail.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s begin with the blog post to understand how to get customer token in Magento using API!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Get Customer Access Token by REST API in Magento 2?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There are&nbsp;<a href=\"https:\/\/developer.adobe.com\/commerce\/webapi\/get-started\/\" target=\"_blank\" rel=\"noreferrer noopener\">three types of users in Magento 2<\/a>&nbsp;\u2013 Admin, Customer, and Guest. The former two requires authentication tokens, while the last one does not require any authentication token from the client to process the API request. Just like the&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/magento-2-api-get-admin-token\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 Admin Access Token<\/a>, the Customer Access Token is essential to process API requests that require customer access.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In order to allow the customers to log in to their accounts and perform actions such as edit account information, add products to wishlist, or anything, they may require to get the customer access token.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To get a customer token in Magento 2 through API, the client needs to send the username and password to the&nbsp;<em>store_url\/rest\/V1\/integration\/customer\/token&nbsp;<\/em>through a POST request. More details about the same are provided below:<\/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:<\/strong>&nbsp;<em>store_url\/rest\/V1\/integration\/customer\/token<\/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\": \"test@meetanshi.com\",\n    \"password\": \"Meet@123\"\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\/05\/Get-Customer-Token-in-Magento-2-700x376-1.png\" alt=\"Get Customer Token in Magento 2\" class=\"wp-image-50801\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Response:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The response will contain the customer admin access token from Magento 2 based on the username and password.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>7wd2wmpjwiba48mvfwg2a7465updzl9d<\/code><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The customer access token is essential in Magento 2 to perform the customer level API actions such as updating profile details. It is also useful for implementing customer log in functionality while developing a Magento-based application. In this blog post, I have provided complete details about Magento 2 API \u2013 Get Customer Token. I hope you\u2019ll find this guide helpful while developing applications based on Magento 2 API.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you still have any queries or doubts regarding the Magento 2 customer login API, feel free to comment. I would be happy to help you! \ud83d\ude07<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, do not forget to share this guide with your Magento friends via social media. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks for reading! \ud83c\udf40<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button btn-orange\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/meetanshi.com\/blog\/magento-2-api-create-new-customer\/\">Magento 2 API \u2013 Create New Customer<\/a><\/div>\n\n\n\n<div class=\"wp-block-button btn-orange\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/meetanshi.com\/blog\/magento-2-api-generate-customer-token-using-customer-id\/\">Magento 2 API \u2013 Generate Customer Token Using Customer ID<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hello, Magento peeps! Magento 2\u00a0is amazing, and so does its API. In my last post, I talked about creating a new customer account using\u00a0Magento 2&#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-2566","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2566","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=2566"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2566\/revisions"}],"predecessor-version":[{"id":17949,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2566\/revisions\/17949"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=2566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=2566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=2566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}