Demonstrates connecting to Twitter API using oAuth 1.0a. oAuth 1.0a header generated purely using Java 8 without 3rd party application.
-
Check TwitterOauthHeaderGenerator to directly see the code to generate oAuth 1.0a Authorization header.
-
Sample code to connect to Twitter API using RestTemplate available here
-
This application also contains a SpringBoot based REST service which checks if a Twitter handle follows another. You can run the application by executing the main method of TwitterPlayApplication and then access the Swagger UI to try out the webservice at http://localhost:8090/swagger-ui.html
Set following environment variables with your API keys before running the application or integration tests.
twitter_oauth_accessToken=<ACCESS_TOKEN>;
twitter_oauth_accessTokenSecret=<ACCESS_TOKEN_SECRET>;
twitter_oauth_consumerKey=<CONSUMER_KEY>;
twitter_oauth_consumerSecret=<CONSUMER_KEY_SECRET>;
API keys can be generated after creating developer account at Twitter