iam getting this error message when build simple app

Getting user info from: http://localhost:9999/uaa/user Could not fetch user details: class org.springframework.web.client.RestClientException, Could not extract response: no suitable HttpMessageConverter found for response type [interface java.util.Map] and content type [text/html;charset=UTF-8]

however i sure the content type is json

this is the github repository https://github.com/ashraf-revo/oauth

this is server

@SpringBootApplication
public class AuthServerApplication {

public static void main(String[] args) {
    SpringApplication.run(AuthServerApplication.class, args);
}
}

@Order(1)
@Configuration
@EnableWebSecurity
class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws     Exception {
      auth.inMemoryAuthentication().withUser("ashraf").password("ashraf").roles("user");
}

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/user").authenticated().and().formLogin();
}

@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
}
}

@Configuration
class OAuth2ServerConfig {
private static final String RESOURCE_IDS = "revo";

@Configuration
@EnableResourceServer
protected static class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {
    @Override
    public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
        resources.resourceId(RESOURCE_IDS);
    }

    @Override
    public void configure(HttpSecurity http) throws Exception {

        http.authorizeRequests().antMatchers("/user").authenticated();
    }
}

@Configuration
@EnableAuthorizationServer
protected static class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {
    @Autowired
    TokenStore tokenStore;

    @Autowired
    private AuthenticationManager authenticationManager;

    @Override
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
        clients.inMemory().withClient("revo")
                .resourceIds(RESOURCE_IDS)
                .authorizedGrantTypes("authorization_code", "implicit")
                .authorities("ROLE_CLIENT")
                .scopes("read", "write")
                .secret("revo");
    }

    @Bean
    public TokenStore tokenStore() {
        return new InMemoryTokenStore();
    }

    @Override
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
        endpoints.tokenStore(tokenStore)
                .authenticationManager(authenticationManager);
    }
}

}

this is the client

@SpringBootApplication
public class ClientApplication {

public static void main(String[] args) {
    SpringApplication.run(ClientApplication.class, args);
}
}

@Configuration
@EnableOAuth2Sso
class SecurityConfigurer extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().mvcMatchers("/home").authenticated();
}
}

 @Configuration
 class MvcConfigurer extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController("/").setViewName("index");
    registry.addViewController("/home").setViewName("home");
}
}
2

There are 2 answers

0
RoshanKumar Mutha On

If you can control the server response, modify it to set the Content-type to application/json.

Please try,

@RequestMapping(value = "/user", method = RequestMethod.GET, 
produces = "application/json; charset=utf-8")
2
amourling On

you may consider spring-boot version and spring-cloud version,choose a not latest version,like spring-boot-1.4.4.RELEASE and spring-cloud-Camden.SR5;because i had same trouble and resolved by this way