【问题标题】:Symfony3 JWT Authentication with LexikJWTAuthenticationBundle drops error on token generation使用 LexikJWTAuthenticationBundle 的 Symfony3 JWT 身份验证在生成令牌时出现错误
【发布时间】:2016-09-05 17:27:25
【问题描述】:

我刚刚安装并配置了LexikJWTAuthenticationBundle,如提供的示例所示。

但是当我尝试生成令牌时

curl -X POST http://localhost:8000/api/login_check -d _username=johndoe -d _password=test

我使用了正确的用户名和密码

我明白了:

{"error":{"code":500,"message":"Internal Server Error","exception":[{"message":"Failed to load private key \"\/home\/web\/symfony\/app\/var\/jwt\/private.pem\". Did you correctly configure the corresponding passphrase?

如何调试此错误?

【问题讨论】:

  • 如果您需要知道的所有内容都在错误消息中,您想调试什么?当你创建密钥时你设置了密码,现在你应该在 bundle config pass_phrase 中设置它或者生成没有密码的密钥。
  • 哎呀!非常感谢!!

标签: symfony lexikjwtauthbundle


【解决方案1】:

请先在 app/config/security.yml 文件中设置提供者,如下所示:-

providers:
        in_memory:
            memory:
                users: 
                    johndoe:
                        password: test
                        roles: 'ROLE_USER'

完成上述设置后,您可以运行以下命令,运行以下命令后您将获得令牌,使用该令牌进行您的请求:

 curl -X POST http://localhost:8000/api/login_check -d _username=johndoe -d _password=test

有关设置的更多信息,请参阅以下链接:- enter link description here

【讨论】:

    猜你喜欢
    • 2021-11-02
    • 2023-02-24
    • 1970-01-01
    • 2019-09-20
    • 2018-03-05
    • 2016-10-20
    • 2021-10-12
    • 2013-02-16
    • 2020-10-24
    相关资源
    最近更新 更多