I am using the following libraries:
- spring-security-oauth2-2.0.9
- spring-4.2.1
- Gson - 2.2.4
and configured GsonHttpMessageConverter in applicationContext.xml:
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.json.GsonHttpMessageConverter">
<property name="gson" ref="gson"/>
<property name="supportedMediaTypes" value="application/json" />
<property name="prefixJson" value="false"/>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
Added :
<bean id="gsonFactoryBean" class="org.springframework.http.converter.json.GsonFactoryBean">
<property name="dateFormatPattern" value="yyyy'-'MM'-'dd"/>
<property name="disableHtmlEscaping" value="true"/>
<property name="prettyPrinting" value="true"/>
<!-- <property name="gson" ref="gson"/>-->
</bean>
<bean id="gsonBuilder" class="com.google.gson.GsonBuilder">
<property name="dateFormat" value="yyyy'-'MM'-'dd" />
</bean>
By default spring-oauth2 uses jackson-converter to serialize/deserialize json. With including jackson libraries, I am not able to get the oauth token from spring TokenEndPoint service. When I comment the message-converters tag, I am able to get oauth token. Please let me know how I can use GsonHttpMessageConverter to get the oauth token, or is there any other way to obtain oauth token.
When debugged the GsonHttpMessageConverter code, it throws HttpMessageNotWritableException, please help. It seems that OAuth2AccessToken.java has expiration attribute which is java.util.Date type, can this be a problem with the configured converter. This converter we need for POST-ing json dates in that format. please help
Thanks in advance.