Rest api getting customer token does not work
Steps to reproduce
- curl to magento 2.0.5 installation to get customer token
- curl -X POST "http://youdomain/index.php/rest/V1/integration/customer/token"
-H "Content-Type:application/json"
-d '{"username":"[email protected]", "password":"xxxxxxxx1"}'
Expected result
- a token return
Actual result
- get the following msg: {"message":"You did not sign in correctly or your account is temporarily disabled."}
looks like the issue occurs inside event Manager.php. Any quick fix?
Hi @sheldonli999 I could not reproduce this, I was able to get the customer token. Please make sure that you are entering the correct email & password to the request because the message you provided is the one that gets returned when an incorrect email or password is entered.
Hello,
I got the same issue. After few successful times (in which I could get token), it starts return above message.
I also got the same issue... keep repeating the correct username and password. Still not getting any.
You guys sure the admin account you're trying to login to is not locked? you can try unlocking it using bin/magento
I confirm the same issue. I can login to admin, unlock says The user account "********" was not locked or could not be unlocked, and the rest api request says {'message': 'You did not sign in correctly or your account is temporarily disabled.'}
this suddenly stopped working on my system. I created a second user to test with same results. I'm testing from the admin so my test is like: curl -X POST "http://youdomain/index.php/rest/V1/integration/admin/token" \ -H "Content-Type:application/json" \ -d '{"username":"[email protected]", "password":"xxxxxxxx1"}'
same problem
Has no one found a solution to this yet? Why is there no simple way to unlock customer? For anyone who faces this problem and needed to move ahead first, just head over to vendor/magento/module-integration/Model/CustomerTokenService.php Put this $this->getRequestThrottler()->resetAuthenticationFailuresCount($username, RequestThrottler::USER_TYPE_CUSTOMER);
before $this->getRequestThrottler()->throttle($username, RequestThrottler::USER_TYPE_CUSTOMER);
And when you have 1 request done, remove that part of code.
Magento community has been very slow in fixing this type of low priority bug.
A lot of comments here. Reopening
As @shoguniphicus hinted, the problem resides with the authentication failure/throttling mechanism that is part of the REST API authentication flow. At least that's what happened in the case I had access to.
It keeps track of failed attempts to get a token with an email and the wrong password (in the oauth_token_request_log table). If the failures_count column reaches the max allowed value (which is 6 by default, and supposed to be configurable in the store configuration, though it doesn't seem to be exposed in the admin panel). then authentication fails. A lock_expires_at timestamp is set to some time in the future (equally configurable, by default a few minutes, it seems).
The problem is the timestamp is not checked by the throttling mechanism, which just checks the failure count. The way a locked email is supposed to be cleaned up is via a cron job defined in: module-integration/Cron/CleanExpiredAuthenticationFailures.php which, in turn, calls the clearExpiredFailures method in module-integration/Model/ResourceModel/Oauth/Token/RequestLog.php which deletes all records with lock_expires_at older than the current time.
So this should work as expected, if the cron job was run as intended. I added logging to the above cron job, so I can see that its execute method is not called at all. I don't know how Magento finds what cron jobs to run or why it's not finding this one (some missing registration step perhaps?) , but it seems to me if this problem was fixed, the permanent locking of users from authentication would go away.
A temporary solution would be to run your own cron job that does this cleanup on the database.
{ "message": "You did not sign in correctly or your account is temporarily disabled.", "trace": "#0 /home/public_html/shop/vendor/magento/module-integration/Model/AdminTokenService.php(81): Magento\Integration\Model\Oauth\Token\RequestThrottler->throttle('admin ', 3)\n#1 [internal function]: Magento\Integration\Model\AdminTokenService->createAdminAccessToken(
I have same issue.
The same issue here. Magento 2.1.1 Manual clearing oauth_token_request_log table helps.
yes The same issue here. Magento 2.1.1 Manual clearing oauth_token_request_log table fixed my issue
I was facing the issue and clearing out the oauth_token_request_log table helped and now i can get the token.
I can confirm Magento 2.1.2 still not fixed
the same issue here. Magento 2
Hello I can confirm that Magento 2.1.5 still not fixed.
It is a blocking issue when this API call is used to log admin customer to an internal application without the possibility to reactive this account.
Thanks to provide a fix.
I also had same issue. But i found i am using wrong values. May be I am wrong but below is my finding
- The token api will not work for a customer. Customer and admin accounts are managed separately in magento.
- For getting token need to use username and password, not email and password.
Having the same issue here, Magento 2.1.5, suddenly unable to authenticate through API with rest/V1/integration/admin/token. Can authenticate through Admin Panel. The user is active, it's not blocked.
Responding {"message":"You did not sign in correctly or your account is temporarily disabled."}