# SmartIot.JwtCore **Repository Path**: moot/SmartIot.JwtCore ## Basic Information - **Project Name**: SmartIot.JwtCore - **Description**: No description available - **Primary Language**: C# - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2020-03-07 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # SmartIot.Jwt aspnetcore JWT 使用方法 * 1.在项目中引用 `SmartIot.JwtCore.dll` * 2.在`Startup.cs`的` public void ConfigureServices(IServiceCollection services)`函数中添加组件 ```C# services.AddSmartIotJwtCore(null,null,null); ``` 函数三个参数都是回调函数,定义分别是 ```C# /// /// 用户登录回调 /// public static Func UserLoginFunc; /// /// 用户退出回调 /// public static Func UserLogoutFunc; /// /// 获取用户的回调 /// public static Func GetUserFunc; ``` 需引入命名空间 ```C# using SmartIot.JwtCore; ``` ### 获取 access token post http://localhost:5000/api/authorize ```json { "UserName":"chenqi", "Password":"123456" } ``` 获取 token:此token为access token ### 访问需要accee token的api get http://localhost:5000/api/values http header中添加 Authorization Bearer accesstoken ### 刷新Token post http://localhost:5000/api/authorize/refresh http header中添加 Authorization Bearer accesstoken 接口将返回新的access token