After having authenticated a user with OAuth2, it is useful to know how to call a remote third-party API with the user's OAuth2 account.
You may have noticed that
IndexController
,StockProductController
,ChartIndexController
, andChartStockController
invoke underlying service methods namedgather(…)
. This concept suggests that lookups to third-party providers (Yahoo!) are proceeded.In
IndexServiceImpl
, for example, you can find thegather(String indexId)
method:@Override public Index gather(String indexId) { Index index = indexRepository.findOne(indexId); if(AuthenticationUtil.userHasRole(Role.ROLE_OAUTH2)){ updateIndexAndQuotesFromYahoo(index != null ? Sets.newHashSet(index) : Sets.newHashSet(new Index(indexId))); return indexRepository.findOne(indexId); } return index; }
It is really the
updateIndexAndQuotesFromYahoo(…)
method that bridges the service layer to the third-party API:@Autowired private...