How to test authentication via API with Laravel Passport?

前端 未结 7 1113
轮回少年
轮回少年 2020-12-24 07:55

I\'m trying to test the authentication with Laravel\'s Passport and there\'s no way... always received a 401 of that client is invalid, I\'ll leave you what I\'ve tried:

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-24 08:14

    Laravel Passport actually ships with some testing helpers which you can use to test your authenticated API endpoints.

    Passport::actingAs(
        factory(User::class)->create(),
    );
    

提交回复
热议问题