【发布时间】:2016-07-28 17:57:38
【问题描述】:
我正在使用 jose jwt 库来创建 jwt 令牌,我不确定如何在有效负载中使用声明标签。我想存储用户名和其他一些与之相关的数据。下面是我用来生成代码的代码
byte[] secretKey = Base64UrlDecode("-----BEGIN PRIVATE KEY-----");
DateTime issued = DateTime.Now;
DateTime expire = DateTime.Now.AddHours(10);
var payload = new Dictionary<string, object>()
{
{"iss", "service email"},
{"aud", "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit"},
{"sub", "service email"},
{"iat", ToUnixTime(issued).ToString()},
{"exp", ToUnixTime(expire).ToString()}
};
string token = JWT.Encode(payload, secretKey, JwsAlgorithm.HS256);
return token;
【问题讨论】: