Error when integrate SSO in Spring Security Oauth2

created at 06-02-2022 views: 8

error

Error while integrating SSO with SpringSecurityOauth2

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.”

The problem is that the authorizedGrantTypes type in the configuration of the authorization service is missing the authorization_code configuration.

solution

@Override
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
        clients.inMemory()
                //Configure clientid
                .withClient("admin")
                //Configure clientsecret
                .secret(passwordEncoder.encode("112233"))
                //Configure the validity period of the token
                .accessTokenValiditySeconds(33600)
                //Configure the validity period of the refresh token
                .refreshTokenValiditySeconds(8640000)
                //Used to jump after authorization is successful
                .redirectUris("http://localhost:8081/login")
                //Automatic authorization configuration
                .autoApprove(true)
                .scopes("all")
                //Authorization code mode Configure grant_type, indicating the authorization type
                //.authorizedGrantTypes("authorization_code")
                //Configure grant_type in authorization mode, indicating that the authorization type is authorization code mode
                .authorizedGrantTypes("password","refresh_token","authorization_code")
        ;
    }
created at:06-02-2022
edited at: 06-02-2022: