当前位置:网站首页>Laravel API interface + token authentication login
Laravel API interface + token authentication login
2022-07-23 11:26:00 【I'm Wang Xi】
List of articles
Reference documents
dingo file https://learnku.com/docs/dingo-api/2.0.0/Authentication/1449
passport file https://learnku.com/docs/laravel/8.5/passport/10427
Add extensions
1.laravel Project and directory execution composer require dingo/api to open up api Interface
2. perform composer require laravel/passport=~9.0 Get the token password ( Take the version number , The new version has not been studied yet )
3. perform php artisan migrate Generating token passwords requires a table
4. perform php artisan passport:install Generate security access token (token) Encryption key required
Follow the above steps , You can see in the project ( Here is the old picture ,passport Should use the 9.2 edition )

Have it all. , Success is considered.
To configure
The next step is configuration
Project root execution :php artisan vendor:publish --provider=“Dingo\Api\Provider\LaravelServiceProvider”
appear 
.env Riga
API_STANDARDS_TREE=prs
API_SUBTYPE=wlq
API_PREFIX=api
API_VERSION=v1
API_DEBUG=true // Remember to change to false laravel If the lower version is true If so, Alibaba cloud will prompt risks
config/auth Riga 
The comments here are removed 
Kernel Riga 
routes/auth.php in 
Login and registration code

routes/api.php in 
result
Then go to the interface 
Yes token Just OK 了
Then bring this to other interfaces that need to log in token That's all right.
The front end is placed in the request header Parameters Authorization: Bearer token
for example 
postman request
When logging in 

That's all for now , What is missing will be filled later
Be careful laravel/passport 10.4 Of token Generated by the generation method token It's plain text , And it's like looking up a table I don't know how to use it for the time being So it is recommended to use 9.2 Of ( Here is 10.4 Output effect )
边栏推荐
- Transform: translate (-50%, -50%) border problem
- Redis database and project framework
- 文件上传漏洞原理
- Using pytorch to realize the flower recognition classifier based on VGg 19 pre training model, the accuracy reaches 97%
- Error when PLSQL creates Oracle Database: when using database control to configure the database, it is required to configure the listener in the current Oracle home directory. You must run netca to co
- The problem that GBK codec cannot decode may be caused by the file name
- 高阶函数的应用:手写Promise源码(一)
- 高阶函数的应用:手写Promise源码(四)
- 自定义MVC(下)
- Niuke question brushing record -- MySQL
猜你喜欢

Machine learning algorithm for large factory interview (6) time series analysis

Goodbye if else
D2dengine edible tutorial (1) -- the simplest program

Spark common interview questions sorting

Pywinauto+某应用程序(学习至第9讲)--受阻

Simple implementation of rectangular area block

Scattered notes of machine learning: some concepts and notes

自定义公式输入框

py程序可以运行,但打包出的exe运行提示错误:加载“cv2”二进制扩展时检测到递归。请检查OpenCV安装。

Five methods to prevent over fitting of neural network
随机推荐
Transform: translate (-50%, -50%) border problem
Understanding of closures of JS
Inheritance mode of JS
JS class array objects and methods of class array conversion (ES6, Es5)
my_strcpy的实现(经典,简单,实用,收藏)
Dynamically set the theme color of the card
Pytorch white from zero uses North pointing
Vite X Figma 打造设计师专属的 i18n 插件
JWT header for coding process
php+码云 代码钩子自动更新线上代码
js的闭包的理解
Web Component-自定义元素的生命周期
Pywinauto+某应用程序(学习至第9讲)--受阻
Analysis of flask source code (I) request entry
【6.28】
MySQL之账号管理&&四大引擎&&建库建表
BurpSuite学习笔记
First blog
flex+js实现内部盒子高度跟随其中最大的高度
Solve the problem that the time format of manually querying Oracle database is incorrect (date type)