Skip to content

Spring Boot application integration with Twitter REST API

Notifications You must be signed in to change notification settings

ahmedmq/boot-twitter-api-playground

Repository files navigation

Spring Boot Twitter API Playground

This repo contains multiple Spring Boot applications showcasing integration with Twitter REST APIs using different HTTP clients.

Twitter APIs provide different authentication methods, but this repo contains code to authenticate using application-only technique. In essence, we generate an App only access token(Bearer token) by passing the Twitter consumer key and consumer secret to the /token/oauth endpoint.

The different modules use three different Twitter APIs

API Description
POST https://api.twitter.com/oauth2/token Generate an access token (Bearer token) for app only
GET https://api.twitter.com/2/users/by/username/{username} User details lookup by username
GET https://api.twitter.com/2/users/{id}/liked_tweets List of liked tweets

Modules

twitter-api-retrofit-client

Make use of the Retrofit HTTP client for interfacing with the Twitter API. Spring Cloud provides an abstraction to Retrofit client with Spring Cloud Square dependency

twitter-api-spring-security-openfeign-client

Use the OpenFeign HTTP client for interfacing with the Twitter API. Spring Cloud provides an abstraction to OpenFeign with the Spring Cloud OpenFeign dependency

Also uses Spring Security OAuth Client to execute the client_credentails flow for the Twitter API authentication

twitter-api-spring-security-webclient

Use the Spring Webflux Webclient to perform the HTTP requests in a non-blocking, reactive programming way.

Similar to the OpenFeign module, this also uses Spring Security Oauth Client for executing the OAuth client credentials flow

twitter-api-common

Contains the core domain classes shared across all the above three modules.

Pre-requisites

Get access to the Twitter API by following the steps mentioned here

Releases

No releases published

Packages

No packages published

Languages