当前位置:   article > 正文

Handling OAuth2 error: error=“invalid_grant“, error_description=“A redirect_uri can only be used by_a redirect_uri can only be used by implicit or aut

a redirect_uri can only be used by implicit or authorization_code grant type

2022-05-29 15:45:56.492 INFO 20820 — [nio-8080-exec-9] o.s.s.o.p.e.AuthorizationEndpoint : Handling OAuth2 error: error=“invalid_grant”, error_description=“A redirect_uri can only be used by implicit or authorization_code grant types.”

在SpringSecurityOauth2整合SSO过程中

问题:

首先异常是

2022-05-29 15:45:56.492  INFO 20820 --- [nio-8080-exec-9] o.s.s.o.p.e.AuthorizationEndpoint        : Handling OAuth2 error: error="invalid_grant", error_description="A redirect_uri can only be used by implicit or authorization_code grant types."
  • 1

问题出现在授权服务的配置里的authorizedGrantTypes类型缺少authorization_code配置

解决:

  @Override
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
        clients.inMemory()
                //配置clientid
                .withClient("admin")
                //配置clientsecret
                .secret(passwordEncoder.encode("112233"))
                //配置令牌的有效期
                .accessTokenValiditySeconds(33600)
                //配置刷新令牌的有效期
                .refreshTokenValiditySeconds(8640000)
                //用于授权成功后跳转
                .redirectUris("http://localhost:8081/login")
                //自动授权配置
                .autoApprove(true)
                .scopes("all")
                //授权码模式 配置grant_type,表示授权类型
                //.authorizedGrantTypes("authorization_code")
                //在授权模式配置grant_type,表示授权类型是 授权码模式
                .authorizedGrantTypes("password","refresh_token","authorization_code")
        ;
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

祝您万事顺心,没事点个赞呗,关注一下也行啊,有啥要求您评论哈

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号