以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  哪位大侠研究过jwt规范吗?【已解决】  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=185934)

--  作者:浙江仔
--  发布时间:2023/3/26 20:39:00
--  哪位大侠研究过jwt规范吗?【已解决】

 

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

 

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

 

只有java示例代码

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

 

 

 

 

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

--  作者:有点蓝
--  发布时间:2023/3/26 20:58:00
--  
没玩过,自行研究了:https://www.baidu.com/baidu?ie=UTF-8&word=.net%20jwt

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

--  作者:浙江仔
--  发布时间: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)