I am working on a project and currently writing the backend. I have decided to implement it as a rest api since i need to write a web app as well as a mobile app. I am having problem understanding how do i login the user since rest api are stateless. I have read some material which mention basic authentication (sending login credentials) with each request or Oauth2.0. Basic authentication is not recommended and i don't understand why i should use Oauth2.0 because no third party will be using my api. My question is how should i implement login functionality and what are the standards ?
3条回答 默认 最新
- duanmianhong4893 2017-04-26 10:56关注
You'll need to add a unique
api_token
column for your Users table.$table->string('api_token', 60)->unique();
In Laravel 5.4,
api.php
holds the API routes, you'll need to use an out-of-the-box middleware auth:api, so you can authenticate requests by api_token.Read more http://bootstrapdojo.com/rest-api-laravel-5-4-with-token-authentication/
解决 无用评论 打赏 举报
悬赏问题
- ¥30 数值计算均差系数编程
- ¥15 redis-full-check比较 两个集群的数据出错
- ¥15 Matlab编程问题
- ¥15 训练的多模态特征融合模型准确度很低怎么办
- ¥15 kylin启动报错log4j类冲突
- ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
- ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
- ¥15 onvif+openssl,vs2022编译openssl64
- ¥15 iOS 自定义输入法-第三方输入法
- ¥15 很想要一个很好的答案或提示