title: Spring Boot OAuth2 - Could not obtain user details from token
body: <p>I searched the web for solution of this problem but didn't find any working solution. I'm trying to setup basic Spring Boot OAuth2 Authorization Provider and Client.</p>
  <p>I followed official Spring Boot instructions and created single sign on with Facebook and Github. Then i followed instructions to create Secure Spring Boot Web application.</p>
  <p>I wanted to create my own Authorization Server so I added @EnableAuthorizationServer annotation to Secure Web Application as explained <a href="https://spring.io/guides/tutorials/spring-boot-oauth2/#_social_login_authserver" rel="noreferrer">here</a>. I also added  details of an OAuth2 client as described in a link. I followed further instructions and created a OAuth2 Client.</p>
  <p>I start both applications, visit 127.0.0.1:9999 to open a Client, client redirects me to localhost:8080/login, I enter user details and Authentication Provider redirects me to 127.0.0.1:9999/login and I get an error message:</p>
  <blockquote>
  <p>Authentication Failed: Could not obtain user details from token</p>
  </blockquote>
  <p>This is what gets logged:</p>
  <blockquote>
  <p>INFO 2800 --- [nio-9999-exec-3] o.s.b.a.s.o.r.UserInfoTokenServices      : Getting user info from: http:// localhost:8080/me</p>
  <p>DEBUG 2800 --- [nio-9999-exec-3] o.s.s.oauth2.client.OAuth2RestTemplate   : Created GET request for http:// localhost:8080/me</p>
  <p>DEBUG 2800 --- [nio-9999-exec-3] o.s.s.oauth2.client.OAuth2RestTemplate   : Setting request Accept header to [application/json, application/*+json]</p>
  <p>DEBUG 2800 --- [nio-9999-exec-3] o.s.s.oauth2.client.OAuth2RestTemplate   : GET request for http:// localhost:8080/me resulted in 200 (OK)</p>
  <p>INFO 2800 --- [nio-9999-exec-3] o.s.b.a.s.o.r.UserInfoTokenServices      : 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]]</p>
  </blockquote>
  <p>This is my Client application:</p>
  <pre><code>@EnableAutoConfiguration
  @Configuration
  @EnableOAuth2Sso
  @RestController
  public class ClientApplication {
      
      @RequestMapping(&quot;/&quot;)
      public String home(Principal user) {
          return &quot;Hello &quot; + user.getName();
      }
  
      public static void main(String[] args) {
          SpringApplication.run(ClientApplication.class, args);
      }
  
  }
  </code></pre>
  <p>This is client application YML:</p>
  <pre><code>server:
    port: 9999
  security:
    oauth2:
      client:
        client-id: acme
        client-secret: acmesecret
        access-token-uri: http://localhost:8080/oauth/token
        user-authorization-uri: http://localhost:8080/oauth/authorize
      resource:
        user-info-uri: http://localhost:8080/me
  </code></pre>
  <p>This is my Authorization Provider application:</p>
  <pre><code>@SpringBootApplication
  public class SecurityApp {
  
      public static void main(String[] args) {
          SpringApplication.run(SecurityApp.class, args);
      }
  
  }
  
  @Configuration
  @EnableWebSecurity
  @EnableAuthorizationServer
  public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http
              .authorizeRequests()
                  .antMatchers(&quot;/&quot;, &quot;/home&quot;).permitAll()
                  .anyRequest().authenticated()
                  .and()
              .formLogin()
                  .loginPage(&quot;/login&quot;)
                  .permitAll()
                  .and()
              .logout()
                  .permitAll();
      }
  
      @Autowired
      public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
          auth
              .inMemoryAuthentication()
                  .withUser(&quot;user&quot;).password(&quot;password&quot;).roles(&quot;USER&quot;);
      }
  }
  
  @Configuration
  public class MvcConfig extends WebMvcConfigurerAdapter {
  
      @Override
      public void addViewControllers(ViewControllerRegistry registry) {
          registry.addViewController(&quot;/home&quot;).setViewName(&quot;home&quot;);
          registry.addViewController(&quot;/&quot;).setViewName(&quot;home&quot;);
          registry.addViewController(&quot;/hello&quot;).setViewName(&quot;hello&quot;);
          registry.addViewController(&quot;/login&quot;).setViewName(&quot;login&quot;);
      }
  
  }
  
  @RestController
  public class Controller {
  
      @RequestMapping({ &quot;/user&quot;, &quot;/me&quot; })
      public Map&lt;String, String&gt; user(Principal principal) {
        Map&lt;String, String&gt; map = new LinkedHashMap&lt;&gt;();
        map.put(&quot;name&quot;, principal.getName());
        return map;
      }
  }
  </code></pre>
  <p>This is Application Provider YML:</p>
  <pre><code>security:
    oauth2:
      client:
        client-id: acme
        client-secret: acmesecret
        scope: read,write
        auto-approve-scopes: '.*'
  </code></pre>