title: Error trying to authenticate a web application with Oauth2 and Strava using Spring Boot
body: <p>I’m trying to use Strava to authenticate customers that want to use my web application using Spring Boot, and I’m stuck in this error:</p>
  <blockquote>
  <p>.s.o.c.w.<strong>OAuth2LoginAuthenticationFilter</strong> : Authentication request
  failed:
  org.springframework.security.oauth2.core.OAuth2AuthenticationException:
  [invalid_token_response] An error occurred while attempting to
  retrieve the OAuth 2.0 Access Token Response: Could not extract
  response: no suitable <strong>HttpMessageConverter</strong> found for response type
  [class
  org.springframework.security.oauth2.core.endpoint.<strong>OAuth2AccessTokenResponse</strong>]
  and content type [text/html]</p>
  </blockquote>
  <p>I would appreciate any help to move forward and solve this error. I simplified the reproduction of the error to just 2 classes:</p>
  <pre><code>DemoSecurity.java extending WebSecurityConfigurerAdapter 
  DemoApplication.java as the entry to the application with @SpringBootApplication, 
  </code></pre>
  <p>and you will need to register an app with Strava (<a href="https://www.strava.com/settings/api" rel="nofollow noreferrer">https://www.strava.com/settings/api</a>) to get your <strong>client_secret</strong> and <strong>client_id</strong>. In strava, the callback needs to be added as localhost to run this test.</p>
  <p>Finally, to reproduce the error, you only need to run the application in your IDE and go to http://localhost:8080/login in your browser.</p>
  <p>Thank you very much</p>
  <p>This is my application.yml:</p>
  <pre><code>spring:   
    security:
      oauth2:
        client:
          registration:
            strava:
              provider: strava-provider
              client-id: XXXXX
              client-secret: XXXXXXXXXXXXXXXXX
              client-authentication-method: POST
              authorization-grant-type: authorization_code
              redirect-uri: http://localhost:8080/login/oauth2/code/
              scope:
                - read
          provider:
            strava-provider:
              tokenUri: https://www.strava.com/api/v3/oauth/token/
              authorizationUri: https://www.strava.com/api/v3/oauth/authorize?response_type=code
  </code></pre>
  <p>This is my pom.xml:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
      xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
      
  
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.3.1.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;com.example&lt;/groupId&gt;
      &lt;artifactId&gt;demo&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;demo&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
  &lt;properties&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-oauth2-client&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;org.junit.vintage&lt;/groupId&gt;
                  &lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>This is my DemoApplication.java:</p>
  <pre><code>package com.example.demo;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientAutoConfiguration;
  import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
  
  @SpringBootApplication
  public class DemoApplication {
      public static void main(String[] args) {
          SpringApplication.run(DemoApplication.class, args);
      }
  
  }
  </code></pre>
  <p>This is my DemoSecurity.java:</p>
  <pre><code>package com.example.demo;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
  import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  
  @EnableWebSecurity
  @Configuration
  public class DemoSecurity extends WebSecurityConfigurerAdapter {
  @Override
  protected void configure(HttpSecurity http) throws Exception {
      http
              .authorizeRequests()
              .antMatchers(&quot;/login**&quot;,&quot;/&quot;, &quot;/error&quot;, &quot;/webjars/**&quot;).permitAll()
              .anyRequest()
              .authenticated().and()
              .oauth2Login()
      ;
  }
  
  
  }
  </code></pre>