Error creating bean with name ‘jwtTokenEnhancer‘ defined in class path resource

报错信息

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenEnhancer' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter]: Factory method 'jwtTokenEnhancer' threw exception; nested exception is org.springframework.web.client.UnknownContentTypeException: Could not extract response: no suitable HttpMessageConverter found for response type [interface java.util.Map] and content type [text/html;charset=UTF-8]

报以上错误的原因是应为我们没有配置jwt的key-value参数
我们只需要配置

security:
  oauth2:
    client:
      client-id: member-service
      client-secret: member123
      access-token-uri: http://localhost:8100/oauth/token
      user-authorization-uri: http://localhost:8100/oauth/authorize
    resource:
      jwt:
        key-uri: http://localhost:8100/oauth/token_key
       # 报错增加下列配置即可
        key-value: member123

错误跳转地址错误

error="invalid_grant", error_description="Invalid redirect: http://localhost:8400/login does not match one of the registered values."```

![在这里插入图片描述](https://img-blog.csdnimg.cn/cee3ae68090344fe893b9a41f332fdcc.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5pyJ6Laj55qE54G16a2CX-S4jeS4luS_l-eahOW_gw==,size_20,color_FFFFFF,t_70,g_se,x_16)
场景是为我们访问客户端的接口localhost:8400/member/list准备跳转套登录界面。
在获取授权成功后,发现跳转地址出现问题,使用了我们客户端项目的地址前缀。
解决方案:
![在这里插入图片描述](https://img-blog.csdnimg.cn/5d86dc6fc8a048e69b10fa6a945e35f6.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5pyJ6Laj55qE54G16a2CX-S4jeS4luS_l-eahOW_gw==,size_16,color_FFFFFF,t_70,g_se,x_16)
增加如图所以的配置

错误3

error=“invalid_request”, error_description=“At least one redirect_uri must be registered with the client.”


![在这里插入图片描述](https://img-blog.csdnimg.cn/e714653461114614993c0d3bddf49af3.png)
我们配置了数据库存储客户端的认证信息,数据表中没有配置跳转的URL
![在这里插入图片描述](https://img-blog.csdnimg.cn/51370d15a95f474dbaedec7f76dfb945.png)
解决方案增加跳转地址。


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值