使用restsharp for JWT for JSON解析到对象不起作用

时间:2017-09-25 09:08:35

标签: json jwt restsharp

我正在使用Restsharp来执行RestApi并使用JWT身份验证。代码很简单。我认为响应内容将被反序列化为我的对象类型(AccessTokenInfo),但它不起作用。

log is "token=, expire=0"

我丢失了什么吗?顺便说一下,我记录了response.ContentType是“application / json; charset = UTF-8”,它与RestSharp不兼容吗?

RestClient client = new RestClient(baseUrl);
client.Authenticator = new JwtAuthenticator(jwt);
RestRequest request = new RestRequest(resource, Method.POST);
client.ExecuteAsync<AccessTokenInfo>(request, response => {
   Console.WriteLine("token={0}, expire={1}",response.Data.token, response.Data.expiresIn);
});

响应内容如下:"token":"eyJhbGciOiJSUzI1NiJ9.eyJleHBp_1imaCD7ovhZAbS6iUQ","expiresIn":43199

0 个答案:

没有答案