Laravel API Platform authentication doesn't work

I have a freshly installed Laravel 11 with api-platforms/laravel. The platform has authentication configured via apiToken. After authorization, when trying to make a request via platform, authorization header is not added to it, as a result I get the 401 status. If I send a request from a third-party resource with a correctly added header, authentication is successful, the request is executed correctly.

config/api-platform.php fragment:

    'swagger_ui' => [
        'enabled' => true,
        'apiKeys' => [
            'api' => [
                'type' => 'apiKey',
                'name' => 'Authorization',
                'in' => 'header'
            ]
        ],

    ]

Upvotes: 0

Views: 38

Answers (1)

Motunrayo Koyejo
Motunrayo Koyejo

Reputation: 427

Ensure CORS is not blocking your requests. Then, clear config & cache.

php artisan config:clear
php artisan cache:clear

Upvotes: 0

Related Questions