title: o.s.s.o.provider.endpoint.TokenEndpoint : Handling error: InvalidGrantException, Bad credentials
body: <p>I am developing <strong>Spring Cloud authorization server</strong>, I am not getting any error when I start the server, but when I tried to access the <a href="http://localhost:9000/services/oauth/token" rel="nofollow noreferrer">http://localhost:9000/services/oauth/token</a>, I get the below error.</p>
  
  <p>Could you please guide what the issue is ? I wonder why its saying invalid grant though grant_type is correct ?</p>
  
  <p><strong>PluralsightSpringcloudM4SecureauthserverApplication</strong></p>
  
  <pre><code>@SpringBootApplication
  @EnableAuthorizationServer
  @EnableResourceServer
  @RestController
  public class PluralsightSpringcloudM4SecureauthserverApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(PluralsightSpringcloudM4SecureauthserverApplication.class, args);
      }
  
      @RequestMapping("/user")
      public Principal user(Principal user) {
          return user;
      }
  }
  </code></pre>
  
  <p><strong>ServiceConfig</strong></p>
  
  <pre><code>@Configuration
  public class ServiceConfig extends GlobalAuthenticationConfigurerAdapter {
  
      @Override
      public void init(AuthenticationManagerBuilder auth) throws Exception {
          auth.inMemoryAuthentication()
          .withUser("agoldberg").password("pass1").roles("USER").and()
          .withUser("bgoldberg").password("pass2").roles("USER", "OPERATOR");
      }
  }
  </code></pre>
  
  <p><strong>application.properties</strong></p>
  
  <pre><code>server.port=9000
  security.user.name=richard
  security.user.password=password
  security.user.role=USER
  
  server.contextPath=/services
  security.oauth2.client.clientId=pluralsight
  security.oauth2.client.clientSecret=pluralsightsecret
  security.oauth2.client.authorized-grant-types=authorization_code,refresh_token,password,client_credentials
  security.oauth2.client.scope=toll_read,toll_report
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/nCLgj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nCLgj.png" alt="enter image description here"></a></p>
  
  <p><strong>pom.xml</strong></p>
  
  <pre><code>&lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.4.1.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;spring-cloud-starter-oauth2&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;spring-cloud-starter-security&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;dependencyManagement&gt;
          &lt;dependencies&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-cloud-dependencies&lt;/artifactId&gt;
                  &lt;version&gt;Camden.RELEASE&lt;/version&gt;
                  &lt;type&gt;pom&lt;/type&gt;
                  &lt;scope&gt;import&lt;/scope&gt;
              &lt;/dependency&gt;
          &lt;/dependencies&gt;
      &lt;/dependencyManagement&gt;
  </code></pre>