我有一个应用程序,它在身份验证后提供访问令牌,我想检查令牌是否未过期
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String expires_in;
public boolean isNotExpired() {
return ! Instant.now().isBefore(Instant.parse(expires_in));
}
但在我运行应用程序之后,我得到了错误:
JSON encoding error: Text '3600' could not be parsed at index 4; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Text '3600' could not be parsed at index 4 (through reference chain: com.Auth.AuthInfo["notExpired"])
我怎样才能解决这个问题?
1条答案
按热度按时间nhaq1z211#
为什么要保留3600的值而不是过期的实际日期和时间?
它很容易解决你的问题。如果您想保留令牌的有效期,您还需要令牌的发出时间来检查
current time
-issue time
不大于如下字段的值validFor
.