O'Reilly logo

Spring MVC Cookbook by Alex Bretet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required