Skip to content

开发一个简单的Rails API功能: JWB用户验证。

Notifications You must be signed in to change notification settings

chentianwei411/JsonWebToken-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JsonWebToken的简单应用:

测试:


curl -X POST -d name="wang" -d password="123123" http://localhost:3000/authentication
  • 输出:{"token":"eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJleHAiOjE1MzE2NTg3MzV9.7Ntqzl470OwtT4Q-GKwMz1me53jtmhvTnASwlNWAWlY"}%

curl -v --header "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJleHAiOjE1MzE2NTg3MzV9.7Ntqzl470OwtT4Q-GKwMz1me53jtmhvTnASwlNWAWlY" http://localhost:3000/users

参考资料:

备注:

测试expire, 可以在Token.rb的encode类方法中改: expiration = 0.minutes.from_now.to_i 输入上面的crul,会raise错误提示{"errors":["授权已过期"]}%

About

开发一个简单的Rails API功能: JWB用户验证。

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published