Как добавить пользовательский параметр для веб-API V1/integration/customer/token
мы попробовали
и т.д. / extension_attributes.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
<extension_attributes for="Magento\Integration\Api\CustomerTokenServiceInterface">
<attribute code="devicetoken" type="string"/>
</extension_attributes>
di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Integration\Model\CustomerTokenService">
<plugin name="Drc_Pushnotification_Plugin" type="Drc\Pushnotification\Plugin\ModifyToken" sortOrder="10" disabled="false" />
</type>
</config>
Теперь внутри
public function aroundCreateCustomerAccessToken(\Magento\Integration\Model\CustomerTokenService $subject, callable $proceed,$username, $password)
{
$this->validatorHelper->validate($username, $password);
$this->getRequestThrottler()->throttle($username, RequestThrottler::USER_TYPE_CUSTOMER);
try {
$customerDataObject = $this->accountManagement->authenticate($username, $password);
} catch (\Exception $e) {
$this->getRequestThrottler()->logAuthenticationFailure($username, RequestThrottler::USER_TYPE_CUSTOMER);
$modifiedresult=array();
$modifiedresult['token']=null;
$modifiedresult['status']=404;
$modifiedresult['success']=false;
$modifiedresult['message']="Please check credentials";
echo json_encode($modifiedresult);
exit;
}
$result = $proceed($username, $password);
return $result;
}
не удалось получить данные поста, как мы можем получить вновь добавленный параметр внутри класса ModifyToken
Ожидаемый результат:
device token
должен быть подтвержден в параметре запроса:
{"username":"hardik.pathar@ia.ooo","password":"Drc@1234","devicetoken":"abc123"}