php - Laravel passport - middleware client_credentials bearer token not working

I have a laravel project, use Passport Client Credentials to get Bearer Tokens, I create client id and secret id using
php artisan passport:client --personal
And get
and get bearer/access code from postman like this
but after call other api like this using this barear but not working
Route::middleware('client_credentials')->post('/test',[ApiController::class, 'va_bills']);
and the output just
{
"message": "Unauthenticated."
}
But if I change the route to be a closure function its work like this
Route::middleware('client_credentials')->post('/test', function (Request $request) {
echo 'nice';
});
I have add this to kernel.php
protected $routeMiddleware = [
..
'client_credentials' => \Laravel\Passport\Http\Middleware\CheckClientCredentials::class,
..
and change the driver
'api' => [
'driver' => 'passport',//instead of token
'provider' => 'users',
'hash' => false,
],
I have also add this to .htaccess,
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
but for your info I dont have .htaccess before and I run my app usingphp artisan serve
I have read many solution but still not work,
can some one help me to out from this problem? Thank you for your time.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: 403 this action is unauthorized.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.