title: Spring Oauth2 Authorization Server
body: <p>I setting the Spring Configuration Below:</p>
  
  <pre><code>@EnableAuthorizationServer
  @EnableWebSecurity
  @Configuration
  public class Oauth2Provider extends WebSecurityConfigurerAdapter implements
          AuthorizationServerConfigurer {
  
      /*
       * @Autowired private TokenStore tokenStore;
       */
  
      @Configuration
      protected static class AuthenticationConfiguration extends
              GlobalAuthenticationConfigurerAdapter {
  
          @Override
          public void init(AuthenticationManagerBuilder auth) throws Exception {
              auth.inMemoryAuthentication().withUser("user").password("password")
                      .roles("USER").and().withUser("admin").password("password")
                      .roles("USER", "ADMIN");
          }
  
      }
  
      @Override
      public void configure(AuthorizationServerSecurityConfigurer security)
              throws Exception {
          // TODO Auto-generated method stub
          security.allowFormAuthenticationForClients();
  
      }
  
      @Override
      public void configure(ClientDetailsServiceConfigurer clients)
              throws Exception {
  
          // TODO Auto-generated method stub
          clients.inMemory()
                  .withClient("my-trusted-client")
                  .authorizedGrantTypes("password", "authorization_code", "refresh_token", "implicit")
                  .authorities("ROLE_CLIENT", "ROLE_TRUSTED_CLIENT", "ROLE_ANONYMOUS")
                  .scopes("read", "write", "trust")
                  .secret("secret")
                  .accessTokenValiditySeconds(60);
      }
  
      @Override
      public void configure(AuthorizationServerEndpointsConfigurer endpoints)
              throws Exception {
          // TODO Auto-generated method stub
  
      }
  
  }  
  </code></pre>
  
  <p>And Maven Setting is Below:</p>
  
  <pre><code>&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.0.5.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>I Access : 
  <a href="http://localhost:8080/oauth/token" rel="noreferrer">http://localhost:8080/oauth/token</a> 
  Payload
  grant_type=password&amp;password=password&amp;username=user&amp;scope=read&amp;client_id=my-trusted-client&amp;client_secret=secret</p>
  
  <p>But I receive error below:</p>
  
  <pre><code>{
  error: "unsupported_grant_type"
  error_description: "Unsupported grant type: password"
  }
  </code></pre>