Respond with status code 401 on authentication failure using Laravel and Passport?

前端 未结 3 2320
迷失自我
迷失自我 2021-02-19 22:11

I\'m configuring a Laravel project to use Passport token authentication. Everything seems to be working, but when the auth:api middleware fails, it responds to the

3条回答
  •  野性不改
    2021-02-19 22:58

    You can solve it by sending this header with your request.

    Accept : application/json
    

    This will send this message with 401 status code.

    {
        "message": "Unauthenticated."
    }
    

提交回复
热议问题