title: Missing grant type error
body: <p>I am just trying to learn OAuth. I wrote some code to test it out. when I am submitting a request I am getting 
  {
      "error": "invalid_request",
      "error_description": "Missing grant type"
  }</p>
  
  <p>error in postman. </p>
  
  <pre><code>import java.util.Optional;
  
  //import static org.assertj.core.api.Assertions.tuple;
  
  import java.util.stream.Stream;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import org.springframework.security.core.userdetails.User;
  
  //import org.omg.PortableInterceptor.ACTIVE;
  import org.springframework.boot.CommandLineRunner;
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.data.jpa.repository.JpaRepository;
  import org.springframework.security.authentication.AuthenticationManager;
  import org.springframework.security.core.authority.AuthorityUtils;
  import org.springframework.security.core.userdetails.UserDetails;
  import org.springframework.security.core.userdetails.UserDetailsService;
  import org.springframework.security.core.userdetails.UsernameNotFoundException;
  import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
  import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
  import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
  import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
  import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
  import org.springframework.stereotype.Service;
  
  import lombok.AllArgsConstructor;
  import lombok.Data;
  import lombok.NoArgsConstructor;
  
  @SpringBootApplication
  public class SpringAuthServiceApplication {
  
      @Bean
      CommandLineRunner clr(AccountRepository accountRepository){
          return args -&gt; {
              Stream.of("name1, password1", "name2, password2", "name3, password3", "name4, password4")
              .map(tpl -&gt; tpl.split(",") )
              .forEach(tpl -&gt; accountRepository.save(new Account(tpl[0], tpl[1], true)));
          };
  
  
      }
  
      public static void main(String[] args) {
          SpringApplication.run(SpringAuthServiceApplication.class, args);
      }
  }
  
  
  @Configuration
  @EnableAuthorizationServer
  class AuthServiceConfiguration extends AuthorizationServerConfigurerAdapter{
      private final AuthenticationManager authenticationManager;
  
      public AuthServiceConfiguration(AuthenticationManager authenticationManager) {
          this.authenticationManager = authenticationManager;
      }
  
      @Override
      public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
          clients
          .inMemory()
          .withClient("html5")
          .secret("password")
          .authorizedGrantTypes("password")
          .scopes("openid");
  
      }
  
      @Override
      public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
          endpoints.authenticationManager(this.authenticationManager);
      }
  
  
  
  }
  
  
  @Service
  class AccountUserDetailService implements UserDetailsService{
  
      private final AccountRepository accountRepository;
  
      public AccountUserDetailService(AccountRepository accountRepository) {
  //      super();
          this.accountRepository = accountRepository;
      }
  
  
      @Override
      public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
          // TODO Auto-generated method stub
          return accountRepository.findByUsername (username)
                  .map(account -&gt; new User(account.getUsername(),
                          account.getPassword(), account.isActive(), account.isActive(), account.isActive(), account.isActive(),
                          AuthorityUtils.createAuthorityList("ROLE_ADMIN", "ROLE_USER") )
                          )
                  .orElseThrow(() -&gt; new UsernameNotFoundException("Couldn't fine user name " + username + "!") ) ;
      }
  
      /*@Override
      public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
          return accountRepository.findByUsername(username)
                  .map(account -&gt; {
                      boolean active = account.isActive();
                      return new User(
                              account.getUsername(),
                              account.getPassword(),
                              active, active, active, active,
                              AuthorityUtils.createAuthorityList("ROLE_ADMIN", "ROLE_USER"));
                  })
                  .orElseThrow(() -&gt; new UsernameNotFoundException(String.format("username %s not found!", username)));
      }*/
  
  }
  
  
  
  interface AccountRepository extends JpaRepository&lt;Account, Long&gt;{
      Optional&lt;Account&gt; findByUsername(String username); 
  }
  
  
  
  @Data 
  @NoArgsConstructor
  @AllArgsConstructor
  @Entity
  class Account{
  
      public Account(String username, String password, boolean active) {
          //super();
          this.username = username;
          this.password = password;
          this.active = active;
      }
  
      @GeneratedValue @Id
      private long id; 
      private String username, password;
      private boolean active;
  
  
  }
  </code></pre>
  
  <p><strong>Here is what I am sending in postman:</strong></p>
  
  <p>In the header tab: 
  Content-Type: application/json
  Authorization: Basic aHRtbDU6cGFzc3dvcmQ=</p>
  
  <p>In the Authorization tab: 
  type is Basic Auth
  Username: html5
  Password: password</p>
  
  <p>Body tab, selected form data and sending the following:</p>
  
  <p>username: username
  password: password1
  grant_type: password
  scope: openid
  client_id: html5
  client_secret: password</p>
  
  <p><a href="https://i.stack.imgur.com/FDJv8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FDJv8.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/BuRK7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BuRK7.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/67oiI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/67oiI.png" alt="enter image description here"></a></p>