【问题标题】:If Gson mapper is chosen, the oauth token response is empty如果选择 Gson 映射器,则 oauth 令牌响应为空
【发布时间】:2018-02-02 14:26:19
【问题描述】:

当我在application.properties中设置spring.http.converters.preferred-json-mapper=gson属性并添加gson依赖时,没有返回oauth令牌(返回的json为空)。
将该属性设置为 spring.http.converters.preferred-json-mapper=jackson 使其再次工作。
我们使用 Gson 作为主要解析器,我们无法迁移到 Jackson,您对这个问题有什么想法吗?

我在 Github 上为这个问题创建了一个项目 (https://github.com/marcellom/sample-oauth2-spring-gson),你可以克隆它并按照 README 中的说明进行操作。

依赖关系:

  • Spring Boot:1.5.6.RELEASE
  • Gson:2.8.0
  • spring-security-oauth2: 2.2.0.RELEASE

提前谢谢你!

【问题讨论】:

  • Spring 为Jackson 提供OAuth2AccessTokenJackson2Serializer,对于Gson,您必须自己提供。

标签: spring spring-security oauth


【解决方案1】:

谢谢chimmi!我通过为 Gson 添加自定义序列化程序解决了这个问题。

【讨论】:

    猜你喜欢
    • 2019-11-05
    • 2023-04-04
    • 2014-08-13
    • 1970-01-01
    • 2014-10-05
    • 1970-01-01
    • 2018-05-04
    • 1970-01-01
    • 2023-03-13
    相关资源
    最近更新 更多