Laravel实现简单的API认证

个人总结Laravel - API认证的几个步骤:

1、为 User 添加 api_token 字段;

2、在 User 模型中的 $fillable$hidden 添加 api_token 字段 ;

3、用户创建时默认生成 api_token ;

4、为 api.php 路由添加 auth:api 中间件 ;

链接: https://segmentfault.com/a/1190000006215513

https://gistlog.co/JacobBennett/090369fbab0b31130b51


另有一详细的API认证方式,以后详细研究再补充:

Laravel 的 API 认证系统 Passport

猜你喜欢

转载自blog.csdn.net/carter_yu/article/details/75315355
今日推荐