title: Spring cannot configure authorization server
body: <p>I created a simple authorization server, but cannot configure it. </p>
  
  <ol>
  <li>Start both apps (8080 is for auth server and 9999 is for client).</li>
  <li>Go to <code>localhost:9999/client</code> and get redirected to <code>localhost:8080/login</code> (as expected).</li>
  <li>Fill the login form with <em>user/user</em>.</li>
  <li>Get redirected to <code>localhost:9999/client</code> (as expected), but have <code>Hello, null</code> instead of <code>Hello, user</code>.</li>
  </ol>
  
  <p>However, if I go straight to <code>localhost:8080/me</code>, I have <code>{"name":"user"}</code>. How can I retrieve <code>Hello, user</code>?</p>
  
  <p><strong>Authorization server</strong></p>
  
  <pre><code>@RestController
  @EnableAuthorizationServer
  @SpringBootApplication
  public class Application extends WebSecurityConfigurerAdapter {
  
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  
      @GetMapping({ "/user", "/me" })
      public Map&lt;String, String&gt; user(Principal principal) {
          return Collections.singletonMap("name", principal == null ? "null" : principal.getName());
      }
  
      @Override
      protected void configure(AuthenticationManagerBuilder auth) throws Exception {
          auth.inMemoryAuthentication()
                  .withUser("user").password("user").authorities(AuthorityUtils.NO_AUTHORITIES);
      }
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http.formLogin();
      }
  }
  </code></pre>
  
  <p><strong>Application's properties</strong></p>
  
  <pre><code>security:
    oauth2:
      client:
        client-id: clientid
        client-secret: clientsecret
        scope: read,write
        auto-approve-scopes: '.*'
  </code></pre>
  
  <p><strong>Client</strong></p>
  
  <pre><code>@Configuration
  @EnableAutoConfiguration
  @EnableOAuth2Sso
  @RestController
  public class Client {
  
      @GetMapping("/")
      public String home(Principal principal) {
          return "Hello, " + principal.getName();
      }
  
      public static void main(String[] args) {
          new SpringApplicationBuilder(Client.class)
                  .properties("spring.config.name=client").run(args);
      }
  
  }
  </code></pre>
  
  <p><strong>Client's properties</strong></p>
  
  <pre><code>server:
    port: 9999
    context-path: /client
  security:
    oauth2:
      client:
        client-id: clientid
        client-secret: clientsecret
        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><strong>UPDATE:</strong><br>
  I downloaded <a href="https://github.com/spring-guides/tut-spring-boot-oauth2/tree/master/auth-server" rel="nofollow noreferrer">a tutorial</a> when all works, but it has <a href="https://github.com/spring-guides/tut-spring-boot-oauth2/blob/master/auth-server/src/main/java/com/example/SocialApplication.java#L81" rel="nofollow noreferrer">ssoFilter</a> that is only for OAuth2 authentication. I just want to configure it with <code>loginForm</code>.<br>
  I have also shared a temporary <a href="https://github.com/delverdev/login-server-example" rel="nofollow noreferrer">example</a> on GitHub. I think it will be easier to look up the problem with it.</p>