I am getting the Token from api call /V1/integration/customer/token I want to get the user id from this jwt token. How i can get it in magento2.4.5 ?
1 Answer
Inject \Magento\JwtUserToken\Model\Reader
and then call read($token) on it.
In PHP8.1 this looks like
public funtion __construct(private \Magento\JwtUserToken\Model\Reader $jwtReader) {
}
public function test() {
$context = $this->jwtReader->read($token);
$userId = $context->getUserContext()->getUserId();
}