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…
- 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 ...
Get Spring MVC Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.