Connecting to Twitter
Twitter allows access to a user account through an OAuth workflow; from our web application, the user is redirected to a Twitter page to authorize the Twitter application in order to access his/her account. The user is then redirected back to our web application. In this recipe, we'll implement this OAuth workflow.
Getting ready
You need an existing Twitter application. Refer to the Creating a Twitter application recipe.
We will use a JSP, so make sure that the Maven dependency for JSTL is declared in your pom.xml
file and the corresponding ViewResolver
bean is declared in your Spring configuration class. For more details, refer to the Using a JSP view recipe in Chapter 3, Using Controllers and Views.
How to do it…
Here are the steps to implement the Twitter OAuth workflow:
- Add the Maven dependencies for Spring Social and Spring Social Twitter in
pom.xml
:<dependency> <groupId>org.springframework.social</groupId> <artifactId>spring...