lexikjwtauthenticationbundle{quot;code";:401,“message";:“坏凭证”}

lexikjwtauthenticationbundle{quot;code";:401,“message";:“坏凭证”},authentication,jwt,Authentication,Jwt,我想将jwtauthentificationbundle与fosuserbundle集成,以便为我的REST APi生成一个令牌,但当我使用postman测试它时: 邮递 这是我的安全。yml: 安全: 编码器: FOS\UserBundle\Model\UserInterface:bcrypt providers: fos_userbundle: id: fos_user.user_provider.username firewalls: dev:

我想将jwtauthentificationbundle与fosuserbundle集成,以便为我的REST APi生成一个令牌,但当我使用postman测试它时: 邮递 这是我的安全。yml:

安全: 编码器: FOS\UserBundle\Model\UserInterface:bcrypt

providers:
    fos_userbundle:
        id: fos_user.user_provider.username


firewalls:

    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false


    login:
        pattern:  ^/api/login
        stateless: true
        anonymous: true
        form_login:
            check_path:               /api/login_check
            username_parameter: username
            password_parameter: password
            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:
        anonymous: ~


access_control:
        - { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/api,       roles: IS_AUTHENTICATED_FULLY }
这是我的路线。yml:

app:
resource: '@AppBundle/Controller/'
type: annotation

app_api:
    resource: '@AppBundle/Controller/Api'
    type: annotation
api\u登录\u检查: 路径:/api/登录检查

NelmioApiDocBundle: 资源:“@NelmioApiDocBundle/Resources/config/routing.yml” 前缀:/api/doc

fos_用户: 资源:“@FOSUserBundle/Resources/config/routing/all.xml”


有什么帮助吗???

您是否尝试在登录防火墙上指定您的提供商? 它给了我这样的东西:

   firewalls:
    # disables authentication for assets and the profiler, adapt it according to your needs
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    login:
        pattern:  ^/api/login
        stateless: true
        anonymous: true
        provider: fos_userbundle
        form_login:
            check_path:               /api/login_check
            provider: main
            success_handler:          lexik_jwt_authentication.handler.authentication_success
            failure_handler:          lexik_jwt_authentication.handler.authentication_failure
            require_previous_session: false

您是否尝试在登录防火墙上指定您的提供商? 它给了我这样的东西:

   firewalls:
    # disables authentication for assets and the profiler, adapt it according to your needs
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    login:
        pattern:  ^/api/login
        stateless: true
        anonymous: true
        provider: fos_userbundle
        form_login:
            check_path:               /api/login_check
            provider: main
            success_handler:          lexik_jwt_authentication.handler.authentication_success
            failure_handler:          lexik_jwt_authentication.handler.authentication_failure
            require_previous_session: false

我发现当我用邮递员测试它时,我必须发送带有标题的数据:content-type应用程序/x-www-form-urlencode我发现当我用邮递员测试它时,我必须发送带有标题的数据:content-type应用程序/x-www-form-urlencode,我找到了解决方案;首先,如您所说:在lofin防火墙中添加提供者,然后在postman中使用内容类型application/x-www-form-urlencoded生成请求头。它很好用!谢谢。是的,我找到了解决办法;首先,如您所说:在lofin防火墙中添加提供者,然后在postman中使用内容类型application/x-www-form-urlencoded生成请求头。它很好用!谢谢