How to implement OAuth Social Login (Single Sign-On)Using Twitter & Spring Boot (Java)— Part 2

Hello👋, Its Rohan Kadam😊

Hello All, Hope you are well. Today we are going to implement OAuth Login using Twitter also called Social Login. Also, remember that Twitter doesn’t support OAuth2 flow its support OAuth 1 follow for Social Login

Step 1:- Create a Spring Boot Project using Spring initializer

Step 2:- Add the following dependencies in your project pom.xml

<!-- https://mvnrepository.com/artifact/org.springframework.social/spring-social-twitter -->

Step 3:- Generate Twitter Credetinals from Twitter Developer Portal

Step 4:- Create Twitter Controller with Endpoints


  1. By calling the endpoint ( /oauth2/authorize/normal/twitter ), a Twitter connection factory is created using the client Key and client secret key. Since Twitter follows OAuth1 follow we will create OAuth1Operations.
  2. Using OAuth1Operations will we fetch request tokens using the following endpoint provided by Twitter.

3. Using request token we will generate Authorize Url

4. On Successful authorization it will redirect ( /oauth2/callback/twitter )

5. Will follow 1 to 2 again on redirect and generate a request token

6. On Using Request Token it will generate Token.

7. Using Twitter Template will generate Twitter Profile.

8. Twitter Profile will return a Twitter User object.

Full Stack Developer, Mumbai, India. A writer at Javarevisted. Check out me:-https://rohan2596.github.io/rohan_kadam_porto/