title: Spring oauth2 /oauth/token invalid credentials
body: <p>Here's my Application.java</p>
  
  <pre><code>@SpringBootApplication
  @RestController
  @EnableResourceServer
  @EnableAuthorizationServer
  public class Application {
  
      @RequestMapping(value = { "/user" }, produces = "application/json")
      public Map&lt;String, Object&gt; user(OAuth2Authentication user) {
          Map&lt;String, Object&gt; userInfo = new HashMap&lt;&gt;();
          userInfo.put("user", user.getUserAuthentication().getPrincipal());
          userInfo.put("authorities", AuthorityUtils.authorityListToSet(user.getUserAuthentication().getAuthorities()));
          return userInfo;
      }
  
  
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  
  
  }
  </code></pre>
  
  <p>WebSecurityConfigurer.java</p>
  
  <pre><code>@Configuration
  public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
      @Override
      @Bean
      public AuthenticationManager authenticationManagerBean() throws Exception {
          return super.authenticationManagerBean();
      }
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http.csrf().disable().authorizeRequests()
                  .antMatchers("/oauth/token").permitAll().anyRequest().authenticated().and().formLogin().and().httpBasic();
      }
  
      @Override
      @Bean
      public UserDetailsService userDetailsServiceBean() throws Exception {
          return super.userDetailsServiceBean();
      }
  
      @Override
      protected void configure(AuthenticationManagerBuilder auth) throws Exception {
          auth
                  .inMemoryAuthentication()
                  .withUser("john.carnell").password("password1").roles("USER")
                  .and()
                  .withUser("william.woodward").password("password2").roles("USER", "ADMIN");
      }
  }
  </code></pre>
  
  <p>My Oauth2Config</p>
  
  <pre><code>@Configuration
  public class OAuth2Config extends AuthorizationServerConfigurerAdapter {
  
      @Autowired
      private AuthenticationManager authenticationManager;
  
      @Autowired
      private UserDetailsService userDetailsService;
  
      @Override
      public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
          clients.inMemory()
                  .withClient("eagleeye")
                  .secret("thisissecret")
                  .authorizedGrantTypes("refresh_token", "password", "client_credentials")
                  .scopes("webclient", "mobileclient");
      }
  
      @Override
      public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
          endpoints
                  .authenticationManager(authenticationManager)
                  .userDetailsService(userDetailsService);
      }
  }
  </code></pre>
  
  <p>I am trying to retrieve an access token though POSTMAN however, this error keeps showing up</p>
  
  <pre><code> {
    "timestamp": 1491436452371,
    "status": 401,
    "error": "Unauthorized",
    "message": "Bad credentials",
    "path": "/oauth/token/"
  }
  </code></pre>
  
  <p>These are values I'm passing in through POSTMAN</p>
  
  <p><a href="https://i.stack.imgur.com/nC01Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nC01Y.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/s95kY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s95kY.png" alt="enter image description here"></a></p>
  
  <p>As you can I'm passing in the correct values so I doubt that it's the credentials that's causing the error</p>