相关疑难解决方法(0)

如何强制Spring Security OAuth 2使用JSON而不是XML?

我已经创建了Spring MVC应用程序并设置了Spring Security OAuth 2.在从我的浏览器调用方法时,我获得了XML:

<oauth>
    <error_description>
        Full authentication is required to access this resource
    </error_description>
    <error>unauthorized</error>
</oauth>
Run Code Online (Sandbox Code Playgroud)

浏览器发送以下标题:

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

当我设置json接受标头时,我得到了JSON.我需要强制我的授权服务器总是发送JSON.没有找到任何解决方案.谢谢.

java spring spring-mvc spring-security spring-security-oauth2

5
推荐指数
1
解决办法
2196
查看次数