It was my mistake. In SecurityConfig I was trying to check If token had a particular role, group etc.
http.csrf().disable().authorizeRequests()
.antMatchers(HttpMethod.POST,"/api/xxxx").hasAuthority(ADMIN_AUTHORITY)
.anyRequest().permitAll()
.and()
.oauth2ResourceServer().jwt();
But when I got token with client credentials there was no role, group etc.
So I changed my code like this and it worked.
http.csrf().disable().authorizeRequests()
.antMatchers(HttpMethod.POST,"/api/xxxx").authenticated()
.anyRequest().permitAll()
.and()
.oauth2ResourceServer().jwt();