cancel
Showing results for 
Search instead for 
Did you mean: 

add method on Login REST API

SOLVED
   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

add method on Login REST API

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!

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: add method on Login REST API

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".

View solution in original post

Re: add method on Login REST API

Hi @gerald_cruz1 

 

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.

View solution in original post

4 REPLIES 4

Re: add method on Login REST API

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".

Re: add method on Login REST API

Hi @gerald_cruz1 

 

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.

Re: add method on Login REST API

Thank you @ronakchauhan427 !

Re: add method on Login REST API

Thanks @verma_mallika this solved my problem! Smiley Happy