0

I create user by execute API call on: "/index.php/rest/all/V1/customers" with json body:

{
   "customer":{
      "id":0,
      "group_id":0,
      "email":"[email protected]",
      "firstname":"Marcin",
      "lastname":"Warzybok"
   },
   "password":"Abcdef123"
}

Returns result:

{
   "id":2,
   "group_id":0,
   "created_at":"2020-09-08 11:58:13",
   "updated_at":"2020-09-08 11:58:13",
   "created_in":"Default Store View",
   "email":"[email protected]",
   "firstname":"Marcin",
   "lastname":"Warzybok",
   "store_id":1,
   "website_id":1,
   "addresses":[
      
   ],
   "disable_auto_group_change":0,
   "extension_attributes":{
      "is_subscribed":false
   }
}

Which means i have a new user registered. When i tried to login in by executing API call on "/rest/all/V1/integration/customer/token" with the following credentials in json body:
{ "username":"[email protected]", "password":"Abcdef123" } , it returns an error:


{
    "message": "The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later.",
    "trace": "#0 [internal function]: Magento\\Integration\\Model\\CustomerTokenService->createCustomerAccessToken('marcinwarzybok@...', 'Abcdef123')\n#1 /bitnami/magento/htdocs/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(95): call_user_func_array(Array, Array)\n#2 /bitnami/magento/htdocs/vendor/magento/module-webapi/Controller/Rest.php(188): Magento\\Webapi\\Controller\\Rest\\SynchronousRequestProcessor->process(Object(Magento\\Framework\\Webapi\\Rest\\Request\\Proxy))\n#3 /bitnami/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(58): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#4 /bitnami/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(138): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callParent('dispatch', Array)\n#5 /bitnami/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(153): Magento\\Webapi\\Controller\\Rest\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#6 /bitnami/magento/htdocs/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(26): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callPlugins('dispatch', Array, Array)\n#7 /bitnami/magento/htdocs/vendor/magento/framework/App/Http.php(116): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#8 /bitnami/magento/htdocs/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\\Framework\\App\\Http->launch()\n#9 /bitnami/magento/htdocs/vendor/magento/framework/App/Bootstrap.php(263): Magento\\Framework\\App\\Http\\Interceptor->launch()\n#10 /bitnami/magento/htdocs/index.php(39): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http\\Interceptor))\n#11 {main}"
}

But i should get some kind of token to make authorize calls. I found something like this: your account is temporarily disabled. But i red this solution provide only temporary solution to a problem.

What about persistence resolve of a problem ? Is anyone have done working rest api integration in Magento 2?

1
  • This is for my own reference: I got same issue in postman and I was struggling to find the issue until I noticed PHPSession ID included in the header. I cleared all cookies and it worked again. Oct 11, 2023 at 1:15

1 Answer 1

1

First of all, make call on /rest/default/V1/integration/customer/token instead of on /index.php/rest/default/V1/integration/customer/token.

Second, make sure you don't make call to mapped subdomains. For example if you mapped localhost or 127.0.0.1 onto mydomain.local in /etc/hosts, don't make call to http://mydomain.local/rest/default/V1/integration/customer/token, but on http://127.0.0.1/rest/default/V1/integration/customer/token

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.