是否可以使用 OidcUserRequest 获取刷新令牌?
Is it possible to get refresh token using OidcUserRequest?
我在 Oauth2UserService 实现 class.
中从 OidcUserRequest 加载 oidcUser
@Override
public OidcUser loadUser(OidcUserRequest userRequest) throws OAuth2AuthenticationException {
OidcUser user = delegate.loadUser(userRequest);
List<GrantedAuthority> rolesAsAuthorities = getRolesAsAuthorities(user);
CustomOidcUserDetailsImpl customUser = new CustomOidcUserDetailsImpl(user, rolesAsAuthorities);
customUser.setFullName(getFullName(user));
customUser.setTelephone(getTelephone(user));
customUser.setEmail(getEmail(user));
return customUser;
}
问题是我只能从 OidcUserRequest 获得 OauthAccessToken 和 IdToken。有什么方法可以在我的服务中获取 Oauth2RefreshToken 吗?
如果我手动交换 授权码 令牌,我会得到 id,access,refresh tokens。
@Autowired
private OAuth2AuthorizedClientService authorizedClientService;
Authentication authentication =SecurityContextHolder.getContext().getAuthentication();
OAuth2AuthorizedClient client = authorizedClientService
.loadAuthorizedClient(
"wso2", // client registrationId
authentication.getName());
Oauth2RefreshToken refreshToken = client.getRefreshtoken();
我在 Oauth2UserService 实现 class.
中从 OidcUserRequest 加载 oidcUser@Override
public OidcUser loadUser(OidcUserRequest userRequest) throws OAuth2AuthenticationException {
OidcUser user = delegate.loadUser(userRequest);
List<GrantedAuthority> rolesAsAuthorities = getRolesAsAuthorities(user);
CustomOidcUserDetailsImpl customUser = new CustomOidcUserDetailsImpl(user, rolesAsAuthorities);
customUser.setFullName(getFullName(user));
customUser.setTelephone(getTelephone(user));
customUser.setEmail(getEmail(user));
return customUser;
}
问题是我只能从 OidcUserRequest 获得 OauthAccessToken 和 IdToken。有什么方法可以在我的服务中获取 Oauth2RefreshToken 吗?
如果我手动交换 授权码 令牌,我会得到 id,access,refresh tokens。
@Autowired
private OAuth2AuthorizedClientService authorizedClientService;
Authentication authentication =SecurityContextHolder.getContext().getAuthentication();
OAuth2AuthorizedClient client = authorizedClientService
.loadAuthorizedClient(
"wso2", // client registrationId
authentication.getName());
Oauth2RefreshToken refreshToken = client.getRefreshtoken();