如果您在令牌的内存存储中使用,是否有办法从Spring Security Oauth2中的TokenStore检索访问和刷新令牌?
是否有任何 endpoints 可以使这更容易,还是有任何其他解决方法?
根据我的分析,TokenEndpoint除了 /oauth/token 之外不提供任何 endpoints :https://docs.spring.io/spring-security/oauth/apidocs/org/springframework/security/oauth2/provider/endpoint/TokenEndpoint.html
1 回答
如果在配置中将TokenStore定义为Bean,则可以将其注入您自己的控制器中:
在控制器中,您可以提供一个读取令牌并返回它们的处理程序:
You should take care that the endpoint itself is properly secured.
然后你可以像这样检索访问令牌:
如果您还想包含刷新令牌,则只需要在处理程序方法中扩展映射 .