Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.springframework.context.annotation.Bean
- import org.springframework.context.annotation.Configuration
- import org.springframework.http.client.ClientHttpRequestInterceptor
- import org.springframework.web.client.RestTemplate
- import org.springframework.web.client.support.OAuth1SigningInterceptor
- @Configuration
- class RestClientConfiguration {
- private val consumerKey = "your-consumer-key"
- private val consumerSecret = "your-consumer-secret"
- @Bean
- fun restClient(): RestClient {
- val restClient = RestClient.builder()
- .restTemplate(oAuth1RestTemplate())
- .build()
- return restClient
- }
- @Bean
- fun oAuth1RestTemplate(): RestTemplate {
- val restTemplate = RestTemplate()
- restTemplate.interceptors.add(oAuth1Interceptor())
- return restTemplate
- }
- @Bean
- fun oAuth1Interceptor(): ClientHttpRequestInterceptor {
- return OAuth1SigningInterceptor(consumerKey, consumerSecret)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement