Flowable integration with Spring boot application giving Bad credentials error

I am trying to figure out a workflow engine that suits our needs. We are building Spring boot application with angular 4 in front end. I tried Camunda BPMN and everything worked like a charm now when I am trying to integrate Flowable with spring boot it throws an error while generating authentication code. The code is exactly same that was used with camunda.

Error
{“error”: “invalid_grant”,“error_description”: “Bad credentials”}

Please advice why I am getting Bad Credentials which works with Camunda BPM and also without any BPM integration.

If you provide a bit more details, then we might be able to answer your question.
What exactly are you using from Flowable?

Best regards,

Tijs

These are some of the dependencies I have included in

build.gradle
dependencies {
compileOnly(‘org.projectlombok:lombok’)
compile(‘org.springframework.boot:spring-boot-starter-data-jpa’)
compile(‘org.springframework.boot:spring-boot-starter-security’)
compile(‘org.springframework.security.oauth:spring-security-oauth2’)
compile(‘org.springframework.security:spring-security-jwt’)
compile(“com.h2database:h2”)
//compile "org.camunda.bpm.extension.springboot:camunda-bpm-spring-boot-starter:2.2.0"
compile "org.flowable:flowable-spring-boot-starter-basic:6.2.0"
runtime(‘mysql:mysql-connector-java’)
testCompile(‘org.springframework.boot:spring-boot-starter-test’)
testCompile(‘org.springframework.security:spring-security-test’)
}

ActivityManager.java

import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.task.api.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ActivityManager {
** @Autowired**
** private RuntimeService runtimeService;**

** @Autowired**
** private TaskService taskService;**


}

Please help…

Do you have a stacktrace where this exception is being thrown from? The “{“error”: “invalid_grant”,“error_description”: “Bad credentials”}” seems to be from a REST endpoint?

An example on setting up a basic project can be found here:

Try to remove all the spring-boot dependencies except the the org.flowable:flowable-spring-boot-starter-basic:6.2.0. It should boot up without error.

Then, you can add for example JPA (see example here: https://github.com/flowable/flowable-engine/tree/3704e4a04c045d3432532dca86341422a19bd84b/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-jpa) or

The application boots up perfectly with no error. This error is thrown while generating access token through postman.
http://localhost:8080/oauth/token?grant_type=password&username=john&password=123456

I am using OAuth2. This works when I remove flowable and use Camunda dependency and I get access token in response. It also works without any workflow engine integrated. This was basic setup that we did initially. But after adding Flowable dependency, it throws an error.

OAuth2Config.php

> @Configuration
> @EnableAuthorizationServer
> public class OAuth2Config extends AuthorizationServerConfigurerAdapter {
> 	@Autowired
> 	@Qualifier("userDetailsService")
> 	private UserDetailsService userDetailsService;
> 
> 	@Autowired
> 	private AuthenticationManager authenticationManager;
> 
>     public static final String RESOURCE_ID = "oauth2";
>     
> 	@Bean
> 	public PasswordEncoder passwordEncoder() {
> 		return new BCryptPasswordEncoder();
> 	}
> 
> 	@Override
> 	public void configure(AuthorizationServerEndpointsConfigurer configurer) throws Exception {
> 		configurer.authenticationManager(authenticationManager);
> 		configurer.userDetailsService(userDetailsService);
> 	}
> 
>      @Override
>      public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
> 		clients.inMemory().withClient("zygote").secret("secret").scopes("read", "write")
> 				.authorizedGrantTypes("password", "refresh_token").resourceIds(RESOURCE_ID);
> 	}
> }

Console Stack trace

o.s.s.a.dao.DaoAuthenticationProvider : User ‘john’ not found
o.s.s.o.provider.endpoint.TokenEndpoint : Handling error: InvalidGrantException, Bad credentials
.m.m.a.ExceptionHandlerExceptionResolver : Resolved exception caused by Handler execution: error=“invalid_grant”, error_description=“Bad credentials”

Please if you could help then it would be great

Thanks
Amit Shukla

Flowable contains additional logic for hooking into Spring security to make it easy for people that have nothing configured out of the box (and add security to embedded rest endpoints), see https://github.com/flowable/flowable-engine/blob/a6def9e52798bb19fa5cf051bf9a56a673b3c560/modules/flowable-spring-boot/flowable-spring-boot-starters/flowable-spring-boot-starter-basic/src/main/java/org/flowable/spring/boot/SecurityAutoConfiguration.java

This AutoConfiguration is part of the basic starter and by the spring security jars on the classpath, it kicks in.
However, since you’ve got a fullblown Oauth2 server, this security config is not needed. Can you try this assumption, and exclude it from loading, like

@SpringBootApplication(exclude = org.flowable.spring.boot.SecurityAutoConfiguration.class)

1 Like

thank you so much joram…it worked…:grinning:

I have couple of questions

  1. Can I use workflow model designed in Camunda modeler and use it in flowable??
  2. Does flowable have desktop modeler to design the workflow ??? just because I designed the entire workflow model using camunda designer and It was a great experience but when I see the plugin…its not that cool…

Hi Amit,

  1. If camunda modeler generates bpm in BPMN2.0 you can import the workflow model,
    We sometimes design the initial flow in third party tool(that generates bpmn2.0 ) and then later import it to flowable modeler.
  2. AFAIK flowable doesnt have a desktop modeler, but you can download the flowabl-modeler and run it as a spring boot application or in an application server like tomcat https://www.flowable.org/downloads.html