Foxtable(狐表)用户栏目专家坐堂 → 哪位大侠研究过jwt规范吗?【已解决】


  共有3830人关注过本帖树形打印复制链接

主题:哪位大侠研究过jwt规范吗?【已解决】

帅哥哟,离线,有人找我吗?
浙江仔
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1326 积分:9603 威望:0 精华:1 注册:2010/7/21 14:20:00
哪位大侠研究过jwt规范吗?【已解决】  发帖心情 Post By:2023/3/26 20:39:00 [只看该作者]

 

https://www.kaoshixing.com/help-document/d118

 

这是考试星数据接口文档,里面涉及jwt规范,一时不知道怎么入手了,有哪位大侠对接过,麻烦提供点指导,谢谢

 

只有java示例代码

https://www.kaoshixing.com/help-document/d120

 

 

 

 

[此贴子已经被作者于2023/3/27 10:54:47编辑过]

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110744 积分:563646 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2023/3/26 20:58:00 [只看该作者]

没玩过,自行研究了:https://www.baidu.com/baidu?ie=UTF-8&word=.net%20jwt

最好让对方提供.net的示例

 回到顶部
帅哥哟,离线,有人找我吗?
浙江仔
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1326 积分:9603 威望:0 精华:1 注册:2010/7/21 14:20:00
  发帖心情 Post By:2023/3/27 10:53:00 [只看该作者]

网上找了jwt.dll

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:jwt.rar

代码大致调通了

Dim secret As String = "XXXXXX"
'Dim st As New Date(1970, 1, 1, 8, 0, 0)
'Dim timestamp As Long = (Date.Now - st).TotalMilliseconds()
Dim action_id As String = "601"
Dim provider As jwt.IDateTimeProvider = New jwt.UtcDateTimeProvider()
Dim now = provider.GetNow()
Dim unixEpoch = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)
Dim secondsSinceEpoch = Math.Round((now - unixEpoch).TotalSeconds)
Dim headers = New Dictionary(Of String, Object)
Dim payload = New Dictionary(Of String, Object) From {
{"exp", secondsSinceEpoch + 1000 * 10},
{"action_id", action_id}
}
Dim key As Byte() = Encoding.UTF8.GetBytes(secret)

'Convert.FromBase64String(str)

Dim algorithm As jwt.algorithms.IJwtAlgorithm = New jwt.algorithms.HMACSHA256Algorithm()
Dim serializer As jwt.IJsonSerializer = New jwt.Serializers.JsonNetSerializer()
Dim urlEncoder As jwt.IBase64UrlEncoder = New jwt.JwtBase64UrlEncoder()
Dim encoder As jwt.IJwtEncoder = New jwt.JwtEncoder(algorithm, serializer, urlEncoder)
Dim token = encoder.Encode(headers, payload, key)
Output.Show(token)

Dim url As String = "https://api.kaoshixing.com/api/company/data/XXXX/?jwt=" & token
Dim jo As New JObject
jo("page") = 1
Dim hc As New HttpClient(url)
hc.Content = jo.ToString()
Dim ss As String = hc.GetData
Output.Show(ss)


 


 回到顶部