Retrieving data from a third-party API with OAuth

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.

How to do it…

  1. You may have noticed that IndexController, StockProductController, ChartIndexController, and ChartStockController invoke underlying service methods named gather(…). This concept suggests that lookups to third-party providers (Yahoo!) are proceeded.
  2. In IndexServiceImpl, for example, you can find the gather(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 ...

Get Spring MVC: Designing Real-World Web Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.