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

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