spring security + oauth2.0登录返回的令牌怎么样用统一结果返回类返回出去,从哪里下手
变成像这样包着的
spring security + oauth2.0登录返回的令牌怎么样用统一结果返回类返回出去,从哪里下手
在授权服务器中添加一个获取token的接口
@RestController
@RequestMapping("/oauth")
public class AuthController {
@Autowired
private TokenEndpoint tokenEndpoint;
@RequestMapping(value = "/token", method = RequestMethod.POST)
public RestResp<Result<OAuth2AccessToken > postAccessToken(Principal principal, @RequestParam Map<String, String> parameters) throws HttpRequestMethodNotSupportedException {
OAuth2AccessToken oAuth2AccessToken = tokenEndpoint.postAccessToken(principal, parameters).getBody();
return new Result<>(oAuth2AccessToken);
}
}
public class Result<T>{
int code;
T data;
String message;
}