繁体   English   中英

为什么不同用户代理的HTTP答案不同? (Spring Security OAuth2令牌端点)

[英]Why is the HTTP answer different for different user agents? (Spring Security OAuth2 Token Endpoint)

RFC表示,当向OAuth2令牌端点发送请求时,响应必须为JSON格式。 使用Spring Security时,会发生奇怪的事情。 可以肯定的是,错误不在我的代码中,我使用了演示应用程序Sparklr2来测试以下内容。 问题是,根据我使用的用户代理,结果是不同的。

我访问网址http://localhost:8084/sparklr2/oauth/token

如果我使用curl,Advanced REST Client,telnet或类似产品,则结果与预期的一样:

{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}

但是,如果我使用Firefox或Chrome,则会得到XML格式的答案:

<oauth><error_description>Full authentication is required to access this resource</error_description><error>unauthorized</error></oauth>

为什么会发生这种奇怪的行为?

Spring可能会Accept标头。 浏览器通常以可接受的格式发送application/xml REST客户端通常包括application/json CURL不发送任何东西(除非您定义它)​​,在这种情况下,Spring可能更喜欢JSON。

至于格式本身,我已经找到了-http://tools.ietf.org/html/draft-richer-oauth-xml-01#section-4.1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM