title: Spring boot oath2 Invalid access token
body: <p>I am trying a very simple example:</p>
  <pre><code>@Configuration
  @EnableAuthorizationServer
  public class AuthorizationServer extends AuthorizationServerConfigurerAdapter {
  
      @Override
      public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
         clients.inMemory()
                      .withClient(&quot;my-api&quot;).secret(&quot;{noop}secret&quot;)
                      .authorizedGrantTypes(&quot;client_credentials&quot;)
                      .scopes(&quot;resource-server-read&quot;, &quot;resource-server-write&quot;);
  
      }
  
      @Override
      public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
          security.allowFormAuthenticationForClients().checkTokenAccess(&quot;permitAll()&quot;);
      }
  }
  </code></pre>
  <p>and the SimpleAuthorizationServerApplication:</p>
  <pre><code>@RestController
  @EnableResourceServer
  @SpringBootApplication
  public class SimpleAuthorizationServerApplication {
      public static void main(String[] args) {
          SpringApplication.run(SimpleAuthorizationServerApplication.class, args);
      }
  
      @RequestMapping(&quot;/validateUser&quot;)
      public Principal user(Principal user) {
          return user;
      }
  
  }
  </code></pre>
  <p>...and then the resource (in another module of the same app):</p>
  <pre><code>@RestController
  public class MyController {
  
      @GetMapping(&quot;hello/world&quot;)
      public String helloWorld() {
          return &quot;helloWorld&quot;;
      }
  
  }
  </code></pre>
  <p>...and</p>
  <pre><code>@EnableResourceServer
  @SpringBootApplication
  public class Application implements WebMvcConfigurer {
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  
  }
  </code></pre>
  <p>Although I do get the token nicely from http://localhost:7070/oauth/token :</p>
  <pre><code>{
      &quot;access_token&quot;: &quot;05a0adeb-751d-4b4b-a9f5-177e82ac9826&quot;,
      &quot;token_type&quot;: &quot;bearer&quot;,
      &quot;expires_in&quot;: 42167,
      &quot;scope&quot;: &quot;resource-server-read resource-server-write&quot;
  }
  </code></pre>
  <p>when calling the resource http://localhost:8080/hello/world with the authorisation bearer token, I get</p>
  <pre><code>{
      &quot;error&quot;: &quot;invalid_token&quot;,
      &quot;error_description&quot;: &quot;Invalid access token: 05a0adeb-751d-4b4b-a9f5-177e82ac9826&quot;
  }
  </code></pre>
  <p>My pom dependencies:</p>
  <pre><code>&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.1.4.RELEASE&lt;/version&gt;
  &lt;/parent&gt;
   &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
            &lt;groupId&gt;org.springframework.security.oauth&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-oauth2&lt;/artifactId&gt;
              &lt;version&gt;2.3.3.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  <p>application.yml on resource end :</p>
  <pre><code>security:
    oauth2:
      resource:
        userInfoUri: http://localhost:7070/oauth/validateUser
  </code></pre>
  <p>It seems that something is wrongly configured, but I cannot figure it out what, therefore I need help.</p>