13 use Magento\Integration\Model\Oauth\TokenFactory as TokenModelFactory;
14 use Magento\Integration\Model\ResourceModel\Oauth\Token\CollectionFactory as TokenCollectionFactory;
25 private $tokenModelFactory;
32 private $accountManagement;
37 private $validatorHelper;
44 private $tokenModelCollectionFactory;
49 private $requestThrottler;
60 TokenModelFactory $tokenModelFactory,
62 TokenCollectionFactory $tokenModelCollectionFactory,
65 $this->tokenModelFactory = $tokenModelFactory;
67 $this->tokenModelCollectionFactory = $tokenModelCollectionFactory;
68 $this->validatorHelper = $validatorHelper;
76 $this->validatorHelper->validate($username, $password);
79 $customerDataObject = $this->accountManagement->authenticate($username, $password);
80 }
catch (\Exception $e) {
84 'The account sign-in was incorrect or your account is disabled temporarily. ' 85 .
'Please wait and try again later.' 90 return $this->tokenModelFactory->create()->createCustomerToken($customerDataObject->getId())->getToken();
104 $tokenCollection = $this->tokenModelCollectionFactory->create()->addFilterByCustomerId(
$customerId);
105 if ($tokenCollection->getSize() == 0) {
109 foreach ($tokenCollection as
$token) {
112 }
catch (\Exception $e) {
124 private function getRequestThrottler()
127 return \Magento\Framework\App\ObjectManager::getInstance()->get(RequestThrottler::class);
129 return $this->requestThrottler;
__construct(TokenModelFactory $tokenModelFactory, AccountManagementInterface $accountManagement, TokenCollectionFactory $tokenModelCollectionFactory, CredentialsValidator $validatorHelper)
createCustomerAccessToken($username, $password)
revokeCustomerAccessToken($customerId)