spring cloud 如何生成过期的Authorization,请写出完整代码
时间: 2023-02-18 17:13:52 浏览: 118
spring cloud相关的代码
Spring Cloud提供的`JwtTokenStore`可以用来生成过期的Authorization。下面是一个示例代码:
```java
// 创建JwtTokenStore
JwtTokenStore jwtTokenStore = new JwtTokenStore(accessTokenConverter());
// 设置token的过期时间
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 10);
Date expirationDate = calendar.getTime();
// 生成Authorization
String authorization = jwtTokenStore.generateAccessToken(user, expirationDate);
```
阅读全文