authentication works fine here, and token is generated.
The problem with other APIs which sends this auth token in header. that token can’t be accessed by Laminas\Authentication\AuthenticationService.
$this->auth itself returns NULL.
Have you verified that the auth data is being correctly written to whatever mechanism you are using to store it? Laminas auth “generally” creates its own session container for persistence of that data. I have no idea how you have it setup so beyond that… Not sure which direction to point you in.
Actually you should use Laminas’ own request and response objects, that contain all headers received and going to send. For doing so write your own authentication adapter factory and pass the request and response classes to your instance. Actually this is the way I would prefer. There might be other ways to inject the request object to your authentication adapter.
Just have a look at this example code.
<?php
// BearerAuthenticationAdapterFactory.php
declare(strict_types=1);
namespace Marcel\Authentication\Adapter\Factory;
class BearerAuthenticationAdapterFactory
{
public function __invoke(ContainerInterface $container): AuthenticationAdapter
{
$request = $container->get('request');
return new BearerAuthenticationAdapter($request);
}
}
In your adapter class just access the header data with something like