OAuthProblemException{error='unsupported_response_type', description='Invalid re

OAuthProblemException{error='unsupported_response_type', description='Invalid response! Response body is not application/json encoded', uri='null', state='null', scope='null', redirectUri='null', responseStatus=0, parameters={}}


之前用了 蓝缘系统的开源代码 整合开涛兄的 OAuth2 shiro集成功能的时候 整合的时候发现 一直报上面这个错误 网上搜了好久都没找到,最后发现

<!-- 采用SpringMVC自带的JSON转换工具,支持@ResponseBody注解 -->
<!--<ref bean="mappingJackson2HttpMessageConverter" /> --> <!-- JSON转换器 -->

<bean
class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="mappingJackson2HttpMessageConverter" />
</list>
</property>
</bean>

如果不把上面的去掉那么 oathu2response返回的json被上面的拦截后处理成了这样

[img]http://dl2.iteye.com/upload/attachment/0111/8656/891f75d4-0c7a-3ffd-b87f-534e016cc093.png[/img]
这样的话 paeseJson方法里 转化json就会报错

如果去掉上面的配置 得到的
    protected void setBody(String body) throws OAuthProblemException {

try {
this.body = body;
parameters = JSONUtils.parseJSON(body);
} catch (JSONException e) {
throw OAuthProblemException.error(OAuthError.CodeResponse.UNSUPPORTED_RESPONSE_TYPE,
"Invalid response! Response body is not " + OAuth.ContentType.JSON + " encoded");
}
}
这里的 body就是

[img]http://dl2.iteye.com/upload/attachment/0111/8658/33777087-b73f-3192-851b-e57776cfdec3.png[/img]
这样就不会报上面那个错误了
可以对比发现两个上面那个数据被加了“//”转义符这个应该就是导致 报错的原因

蓝缘系统里spring-mvc.xml里有一段配置是这样的 把这个去掉后 该错误就解决了,想了下应该是 该 配置拦截了 oathu2的json数据 更改了它的格式 导致 oathu2认为是非法的返回类型 从而报错 。

如果 有人遇到类似的错误可以参考 我的这个解决案例的思路。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值