【问题标题】:How to change the content-type of a request which will be made by ClientCredentialsResourceDetails?如何更改将由 ClientCredentialsResourceDetails 发出的请求的内容类型?
【发布时间】:2017-07-03 20:20:35
【问题描述】:

现在,我正在尝试更改将由 ClientCredentialsResourceDetails 提出的请求的 content-type (org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails)

预期的内容类型:- 即 form/data 或 multipart/form-data

但现在我只能看到/做这个,

ClientCredentialsResourceDetails resourceDetails = new ClientCredentialsResourceDetails();
resourceDetails.setClientAuthenticationScheme(AuthenticationScheme.header);

这段代码只允许我通过以下content-type传递数据,

content-type : application/x-www-form-urlencoded

所以,我想改变它。

谁能给我一个想法?如何做到这一点?

任何帮助感谢...!!!

【问题讨论】:

    标签: java spring-security oauth oauth-2.0 spring-security-oauth2


    【解决方案1】:

    客户端凭据流在 RFC 6749 中定义,“4.4. Client Credentials Grant”和“4.4.2. Access Token Request”如下所述。

    客户端通过使用 "application/x-www-form-urlencoded" 格式添加以下参数向令牌端点发出请求,每个附录 B 的字符编码为 UTF-8 HTTP 请求实体主体:

    因此,期望 Spring Security 和其他 OAuth 客户端库提供使用客户端凭据流将令牌请求的 Content-Type 更改为“application/x-www-for-urlencoded”以外的任何其他值的方法是毫无希望的。

    【讨论】:

    • 我想通过 POST-payload 传递一些数据,但如果我们无法更改内容类型,那么 OAuth 服务器拒绝这样做,即使我们提供了正确的 paryload,这是主要问题对我来说。
    • 你的意思是你的授权服务器不符合规范?如果是这样,您为什么不尝试其他实现方式?
    猜你喜欢
    • 2010-10-31
    • 2018-05-07
    • 2017-11-14
    • 2017-12-09
    • 2018-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-13
    相关资源
    最近更新 更多