如果已配置oauth2授权/资源服务器,则可以尝试以下代码:
@Autowired
private TokenStore tokenStore;
@RequestMapping(method = { RequestMethod.POST, RequestMethod.GET },
value = "/oauth/me")
public Map<String, Object> userInfo (OAuth2Authentication auth)
{
final OAuth2AuthenticationDetails details =
(OAuth2AuthenticationDetails) auth.getDetails();
//token
String accessToken = details.getTokenValue();
//reference
final OAuth2AccessToken accessToken =
tokenStore.readAccessToken(details.getTokenValue());
// clientid
String clientId = auth.getOAuth2Request().getClientId();
}
希望有帮助!