OAUTH TWITTER
How to implement OAuth Social Login (Single Sign-On)Using Twitter & Spring Boot (Java)— Part 2
Hello👋, Its Rohan Kadam😊
Hello, I 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 supports 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 -->
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-twitter</artifactId>
<version>1.1.2.RELEASE</version>
</dependency>
Step 3:- Generate Twitter Credetinals from Twitter Developer Portal
Step 4:- Create Twitter Controller with Endpoints
Note:-
- 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.
- Using OAuth1Operations will we fetch request tokens using the following endpoint provided by Twitter.
https://api.twitter.com/oauth/request_token
3. Using the 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 a Token.
7. Using Twitter Template will generate Twitter Profile.
8. Twitter Profile will return a Twitter User object.