最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Laravel API Platform authentication doesn't work - Stack Overflow

programmeradmin1浏览0评论

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'
            ]
        ],

    ]

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'
            ]
        ],

    ]
Share Improve this question edited Feb 3 at 22:15 undefined 2,47127 silver badges41 bronze badges asked Jan 31 at 10:01 Максим ШептухаМаксим Шептуха 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

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

php artisan config:clear
php artisan cache:clear
发布评论

评论列表(0)

  1. 暂无评论