Open leonchen83 opened 5 years ago
My IDE wasn't cooperating with the APPLICATION_FORM_URLENCODED. In case anyone else has a problem with the import, here it is:
import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED;
Works for me with kotlin + spring.
Here is an example with kotlin + spring:
class ContentTypeInterceptor: ClientHttpRequestInterceptor {
override fun intercept(
request: HttpRequest,
body: ByteArray,
execution: ClientHttpRequestExecution
): ClientHttpResponse {
request.headers.contentType = MediaType.APPLICATION_FORM_URLENCODED
return execution.execute(request, body)
}
}
...
val twitter = TwitterTemplate(a, b, c, d)
twitter.restTemplate.interceptors.add(0, ContentTypeInterceptor())
Summary
spring-social-twitter post tweet failed with dependency spring 5.1.5.RELEASE
Actual Behavior
The exception stack is following.
Expected Behavior
no exception stack and tweet success.
Configuration
NOP
Version
from spring-social-core-1.1.0.RELEASE to recent version spring version: 5.1.5.RELEASE
Sample
The root cause is in
org.springframework.social.oauth1.SigningSupport
line 191but int spring 5.1.5.RELEASE the default content-type change to application/x-www-form-urlencoded;charset:UTF-8 so sign the wrong signature.
workaround with spring 5.1.5.RELEASE