Skip to content

Get Customer details from customer token in M2.4.0

Impossible to process constructor argument Parameter #4 [
MagentoIntegrationApiUserTokenReaderInterface or NULL $reader =
NULL ] of ExperroSSOModelApiCheckoutToken class

Above is the error I get when I try to get customer id from customer token. Below is the functionality, it is working well for M2.4.6 & above but not below that version as

MagentoIntegrationApiUserTokenReaderInterface

class is not present. What should I use for them, please suggest?

use MagentoIntegrationApiUserTokenReaderInterface;

$this->reader = $reader ?? ObjectManager::getInstance()->get(UserTokenReaderInterface::class);

$data = $this->reader->read($customerToken);
$customerId = $data->getUserContext()->getUserId();