Spring Boot Oauth2 - 访问令牌存储在哪里?

Spring Boot Oauth2 - Where is the access token stored?

我有一个 jhipster(spring boot 和 angular)项目,它使用 Keycloak 实现了 oauth2 协议。我设法让应用程序重定向到 keycloak 进行身份验证。我很困惑登录后访问令牌在响应中的位置以及重定向回我的站点后存储在哪里? 我尝试使用 chrome 检查来查看网络,但我似乎找不到访问令牌。

下面是 link 我曾经为我的项目设置 oauth2: https://www.jhipster.tech/security/

URL点击登录时:http://localhost:8080/oauth2/authorization/oidc

使用 OAuth2,身份验证是有状态的,这意味着您有一个用于 Spring 会话的 cookie (JSESSIONID)。

您可以通过在后端使用 SecurityContextHolder.getContext().getAuthentication() 检查上下文来获取更多信息。

感谢大家的回复。使用以下方法设法获取令牌:

SecurityContext securityContext = SecurityContextHolder.getContext();
    OAuth2AuthenticationToken oauth2Token = (OAuth2AuthenticationToken) 
securityContext.getAuthentication();

OAuth2AuthorizedClient client = clientService
            .loadAuthorizedClient(oauth2Token.getAuthorizedClientRegistrationId(), 
oauth2Token.getName());

refreshToken = client.getRefreshToken().getTokenValue();