配置文件定义
security:
oauth2:
resource:
user-info-uri: http://auth-server/me # auth-server 为OAuth2 Server在注册中心的service id
prefer-token-info: true # Use the token info, can be set to false to use the user info.
配置 OAuth2 Rest template
@Bean
@LoadBalanced
public OAuth2RestTemplate restTemplate(UserInfoRestTemplateFactory factory) {
return factory.getUserInfoRestTemplate();
}