1. Spring Social Overview

1.1 Introduction

The Spring Social project enables Spring applications to connect with users' profiles on service providers such as Facebook and Twitter and interact with those services on behalf of the user.

1.2 Socializing applications

The phrase "social networking" often refers to efforts aimed at bringing people together. In the software world, those efforts take the form of online social networks such as Facebook, Twitter, and LinkedIn. Roughly half a billion of this world's internet users have flocked to these services to keep frequent contact with family, friends, and colleagues.

Under the surface, however, these services are just software applications that gather, store, and process information. Just like so many applications written before, these social networks have users who sign in and perform some activity offered by the service.

What makes these applications a little different than traditional applications is that the data that they collect represent some facet of their users' lives. What's more, these applications are more than willing to share that data with other applications, as long as the user gives permission to do so. This means that although these social networks are great at bringing people together, as software services they also excel at bringing applications together

To illustrate, imagine that Paul, is a member of an online movie club. A function of the movie club application is to recommend movies for its members to watch and to let its members maintain a list of movies that they have seen and those that they plan to see. When Paul sees a movie, he signs into the movie club site and checks it off of his viewing list and indicating if he liked the movie or not. Based on his responses, the movie club application can tailor its future suggestions for Paul to see.

On its own, the movie club provides great value to Paul, as it helps him choose movies to watch. But Paul is also a Facebook user. And many of Paul's Facebook friends also enjoy a good movie now and then. If Paul were able to connect his movie club account with his Facebook profile, the movie club application could offer him a richer experience. Perhaps when he sees a movie, the application could post a message on his Facebook wall indicating so. Or when offering suggestions, the movie club could factor in the movies that his Facebook friends liked.

Social integration is a three-way conversation between a service provider, a service consumer, and a user who holds an account on both the provider and consumer. All interactions between the consumer and the service provider are scoped to the context of the user's profile on the service provider.

In the narrative above, Facebook is the service provider, the movie club application is the service consumer, and Paul is the user of them both. The movie club application may interact with Facebook on behalf of Paul, accessing whatever Facebook data and functionality that Paul permits, including seeing Paul's list of friends and posting messages to his Facebook wall.

From the user's perspective, both applications provide some valuable functionality. But by connecting the user's account on the consumer application with his account on the provider application, the user brings together two applications that can now offer the user more value than they could individually.

With Spring Social, an application can play the part of the service consumer, interacting with a service provider on behalf of its users. The key features of Spring Social are:

  • A service provider framework that models the authorization and connection creation process with a service.

  • A connection controller that handles the OAuth exchange between a service provider, consumer, and user.

  • APIs for several service providers such as Facebook, Twitter, LinkedIn, TripIt, GitHub, and Gowalla.

  • A signin controller that enables a user to authenticate to an application by signing into either Facebook or Twitter.

1.3 How to get

Spring Social is divided into the modules described in Table 1.1, “Spring Social Modules”.

Table 1.1. Spring Social Modules

NameDescription
spring-social-coreSpring Social's ServiceProvider connect framework and OAuth support.
spring-social-webSpring Social's ConnectController which uses the ServiceProvider framework to manage connections in a web application environment
spring-social-facebookIncludes Spring Social's Facebook API as well as support for signing into an application through Facebook.
spring-social-twitterIncludes Spring Social's Twitter API as well as support for signing into an application via Twitter.
spring-social-linkedinIncludes Spring Social's LinkedIn API.
spring-social-githubIncludes Spring Social's GitHub API.
spring-social-gowallaIncludes Spring Social's Gowalla API.
spring-social-tripitIncludes Spring Social's TripIt API.
spring-social-testSupport for testing ServiceProvider implementations and API bindings

Which of these modules your application needs will largely depend on what facets of Spring Social you intend to use. At very minimum, you'll need the core module in your application's classpath:

<dependency>
  <groupId>org.springframework.social</groupId>
  <artifactId>spring-social-core</artifactId>
  <version>${org.springframework.social-version}</version>
</dependency>
	  

To let Spring Social handle the back-and-forth authorization handshake between a web application and a service provider, you'll need the web module:

<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-web</artifactId>
<version>${org.springframework.social-version}</version>
</dependency>
	  

The remaining modules are elective, depending on which of the supported service providers you intend for your application to interact with. For example, you'll only need the GitHub module if your application needs to access a user's GitHub profile.

If you are developing against a milestone version, such as 1.0.0.M2, you will need to add the following repository in order to resolve the artifact:

<repository>
  <id>org.springframework.maven.milestone</id>
  <name>Spring Maven Milestone Repository</name>
  <url>http://maven.springframework.org/milestone</url>
</repository>
		

If you are testing out the latest nightly build version (e.g. 1.0.0.BUILD-SNAPSHOT), you will need to add the following repository:

<repository>
  <id>org.springframework.maven.snapshot</id>
  <name>Spring Maven Snapshot Repository</name>
  <url>http://maven.springframework.org/snapshot</url>
</repository>