title: Access user data after login with Spring Boot OAuth2 Client
body: <p>I am trying to build an OAuth2 Client using spring boot to access a custom API.</p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>@SpringBootApplication
  public class MyClient {
      public static void main(String[] args){
          SpringApplication.run(MyClient.class, args);
      }
  }
  </code></pre>
  
  <pre><code>@Configuration
  @EnableOAuth2Sso
  public class ApplicationSecurity extends WebSecurityConfigurerAdapter{
      @Override
      protected void configure(HttpSecurity http) throws Exception{
          http.antMatcher("/**")
          .authorizeRequests().antMatchers("/","/callback","/login**","/error**")
          .permitAll().anyRequest().authenticated();
      }
  }
  </code></pre>
  
  <pre><code>@RestController
  public class HomeController {
      @RequestMapping("/user")
      public String login() {
          String userInfoJson = "get data returned from API somehow";
          return userInfoJson;
      }
  
      @RequestMapping("/callback")
      public void callback(HttpServletResponse response) {
          response.sendRedirect("/user");
      }
  }
  </code></pre>
  
  <p>I have created an application.yml file with all the properties needed and the login process works perfectly, returning the flow to /callback after a successful login.</p>
  
  <p>At that point I should have received a token that I can use to fetch the user's data from the server.</p>
  
  <p>How can I access this token?</p>
  
  <p>Also, does spring boot have any classes to do the token validation process automatically, or do I have to create the request manually?</p>
  
  <p>Thanks</p>