我已经在oauth_client_details表中配置了一些extra_information,我需要将其作为访问令牌响应中的其他数据发送。
尝试调用OAuth2AccessToken.getAdditionalInformation()
,它给出了空
也可以有人解释
Map<String, Object> getAdditionalInformation() in org.springframework.security.oauth2.provider.ClientDetails
最佳答案
我最终这样做了
@Component
public class ClTokenEnhancer implements TokenEnhancer {
private ClientDetailsService clientDetailsService;
public ClTokenEnhancer( ClientDetailsService clientDetailsService ) {
this.clientDetailsService = clientDetailsService;
}
@Override
public OAuth2AccessToken enhance( OAuth2AccessToken accessToken, OAuth2Authentication authentication ) {
ClientDetails clientDetails = clientDetailsService.loadClientByClientId( authentication.getOAuth2Request().getClientId() );
( (DefaultOAuth2AccessToken) accessToken ).setAdditionalInformation( clientDetails.getAdditionalInformation() );
return accessToken;
}
}