i have created REST Api how can i use those REST Api directly from helper?
Curl call is a option is there any other method that we can use?
i have created REST Api how can i use those REST Api directly from helper?
Curl call is a option is there any other method that we can use?
Generally we need to use /V1/integration/customer/token to access token if we need to generate token internal purpose we can just use the interface directly as below:
public function __construct(
\Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService
) {
$this->customerTokenService = $customerTokenService;
}
public function sample(string $email, string $password)
{
$token = $this->customerTokenService->createCustomerAccessToken($email, $password);
}
in di.xml
<route url="/V1/integration/customer/token" method="POST">
<service class="Magento\Integration\Api\CustomerTokenServiceInterface" method="createCustomerAccessToken"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
We can use Service class and method defined for any other APIS