Hi,
is it possible to override the rest api for login?
/rest/V1/integration/customer/token
What im planning to do is, add another function that will populate a custom column on customer_entity with a random generated string.
so I was wondering if it is possible to override the login rest api file.
Thanks!
Solved! Go to Solution.
Yes, It is possible to override API:
you need to change API interface for that.
`webapi.xml`
<route url="/V1/integration/customer/token" method="POST">
<service class="yourVendor\yourModule\Api\CustomerTokenServiceInterface" method="createCustomerAccessToken"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
You can write your own logic into model file which implements `CustomerTokenServiceInterface`. but you have to override all private functions.
If it helps, Please Click "Kudos" and "accept solution".
If you want to override vendor/magento/module-integration/Model/CustomerTokenService.php file, so yes you can override it and add the code for setting some specific column value in customer_entity table.
But you cant change response param just by overriding the file.
Yes, It is possible to override API:
you need to change API interface for that.
`webapi.xml`
<route url="/V1/integration/customer/token" method="POST">
<service class="yourVendor\yourModule\Api\CustomerTokenServiceInterface" method="createCustomerAccessToken"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
You can write your own logic into model file which implements `CustomerTokenServiceInterface`. but you have to override all private functions.
If it helps, Please Click "Kudos" and "accept solution".
If you want to override vendor/magento/module-integration/Model/CustomerTokenService.php file, so yes you can override it and add the code for setting some specific column value in customer_entity table.
But you cant change response param just by overriding the file.