Spring Social, Google's OAuth Client Library for Java and Apache Oltu fulfill the oauth specification and are all good candidates. Every library comes with some predefined providers. Spring Social and Apache Oltu contains some popular platforms like Facebook, Twitter, Github or Google. Google OAuth Client Library for Java comes along with the Google API Client Library for Java in order to connect to Google services. In Spring Social and Google OAuth Client Library those providers are optional.
All three libraries are written in a generic way so that one can connect to any oauth provider. I think that Spring Social could require less integration work than Apache Oltu or Google OAuth Client Library in regard to other Spring modules like Spring Security or MVC. In the end it all boils down to your personal preference for a library.
If you decide for Spring Social, take a look at this quickstart demo (ignore the README.md
and just run ./gradlew bootRun
). It already contains everything you described in the comments of your question:
- authenticate user through a third party
- integrate several platforms in one application and fetch user data on demand (imagine the dropdown menu items for example
Twitter profile
or Timeline
represents facebook.com/get_my_latest_posts
or gym.com/pay_my_membership
)
As you can see in the demo, you can't prevent that your users have to authenticate with every third party once in a time. This happens usually when there is no access or refresh token or the token has expired.
Take a look at the Spring Social documentation on how to add a new service provider.
Summary
All three libraries are extensible and fit your needs. There are many examples on the internet for every library. Spring Social could require less integration work into an existing Spring application.
Your application is just a host for many oauth clients for different services (so no science fiction here). You'll need to think about storing the access and refresh token on a per user basis somewhere (database?). You'll need to provide an after authorization callback url in your application for every service you want to integrate.