小编use*_*432的帖子

API平台-具有JWT身份验证的Swagger UI

我想在Swagger上添加“授权”按钮,如此处所述:https : //api-platform.com/docs/core/jwt#documenting-the-authentication-mechanism-with-swaggeropen-api

我安装了LexikJWTAuthenticationBundle,它与Curl一起正常工作。但是当我浏览到http:// localhost:8000 / api时,我只会看到{"code":401,"message":"JWT Token not found"}

我想念什么吗?

这是我的security.yaml

security:
    encoders:
        App\Entity\User:
            algorithm: bcrypt
    providers:
        db_provider:
            entity:
                class: App\Entity\User
                property: username
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        api_login:
            pattern: ^/api/login
            stateless: true
            anonymous: true
            form_login:
                check_path: /api/login_check
                success_handler: lexik_jwt_authentication.handler.authentication_success
                failure_handler: lexik_jwt_authentication.handler.authentication_failure
                require_previous_session: false
        api:
            pattern: ^/api
            stateless: true
            guard:
                authenticators:
                    - lexik_jwt_authentication.jwt_token_authenticator
        main:
            pattern: ^/
            anonymous: ~
            provider: db_provider
            form_login:
                login_path: app_security_login
                check_path: app_security_login
                csrf_token_generator: security.csrf.token_manager
            logout:
                path: /logout
                target: …
Run Code Online (Sandbox Code Playgroud)

symfony lexikjwtauthbundle api-platform.com

7
推荐指数
2
解决办法
2912
查看次数