The apache configuration I use that works in my virtualhost is
RewriteEngine On
RewriteCond %{HTTP:Authorization} .+
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
Just remember to restart apache to apply the changes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Using Laravel 5.7 I installed passport according to the documentation and generated a personal access token, using
php artisan passport:client --personal
My controllers are as follows:
Route::resource('form.entries', 'API\FormEntryController')->only(['store', 'index', 'destroy'])->middleware('auth:api');
Route::resource('forms', 'API\FormController')->only(['index', 'store'])->middleware('auth:api');
Route::resource('form', 'API\FormController')->only(['show', 'destroy'])->middleware('auth:api');
my guards are set up as follows:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
],
I added use Notifiable, HasApiTokens; (and the heading definition) to my App.php model
I added Passport::routes(); to the end of my \App\Providers\AuthServiceProvider::boot() method
I also added
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
to my htaccess file
...
To generate the token I ran
me (master) formService $ php artisan passport:client --personal
What should we name the personal access client? [Bar Foo Access Client]:
> Foobar
Personal access client created successfully.
Client ID: 4
Client Secret: KKI1EoIXgrv2P9ydZTGa5VyimFJWbVPoRGmMCH0M
Then I make a request using postman ( i also exported the code for cURL in postman )
And get back:
{"message":"Unauthenticated."}
Here's my postman request translated using cURL
curl -X GET \
http://formservice.tst/api/forms \
-H 'Accept: application/json' \
-H 'Authorization: Bearer KKI1EoIXgrv2P9ydZTGa5VyimFJWbVPoRGmMCH0M' \
-H 'Cache-Control: no-cache' \
-H 'Postman-Token: 45295b86-7c66-d4a7-6bb6-3de142f042ac'
Anyone have any idea what I am doing wrong??
Please or to participate in this conversation.