REST API Bonita 6.x - Auth - Error while logging in on the engine API

1
0
-1

Server Enviroment

- CentOS 6.4 (Final);

- Java(TM) SE Runtime Environment (build 1.7.0_45-b18);

- BonitaBPMCommunity-6.2.0-Tomcat-6.0.37 (bundle);

- Postgresql 9.2.6;

REST client

package com.mkyong.rest.client;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.net.MalformedURLException;

import org.apache.http.HttpResponse;

import org.apache.http.client.methods.HttpPost;

import org.apache.http.entity.StringEntity;

import org.apache.http.impl.client.DefaultHttpClient;

public class ApacheHttpClientPost {

// http://localhost:8080/RESTfulExample/json/product/post

public static void main(String[] args) {

try {

DefaultHttpClient httpClient = new DefaultHttpClient();

//HttpPost postRequest = new HttpPost(

// "http://localhost:8080/RESTfulExample/json/product/post");

HttpPost postRequest = new HttpPost("http://:/bonita/loginservice");

//StringEntity input = new StringEntity(

// "{\"qty\":100,\"name\":\"iPad 4\"}");

StringEntity input = new StringEntity("{\"username\":\"myusername\",\"password\":\"mypassword\",\"redirect\":\"false\"}");

input.setContentType("application/json");

postRequest.setEntity(input);

HttpResponse response = httpClient.execute(postRequest);

if (response.getStatusLine().getStatusCode() != 200) {

throw new RuntimeException("Failed : HTTP error code : "

+ response.getStatusLine().getStatusCode());

}

BufferedReader br = new BufferedReader(new InputStreamReader(

(response.getEntity().getContent())));

String output;

System.out.println("Output from Server .... \n");

while ((output = br.readLine()) != null) {

System.out.println(output);

}

httpClient.getConnectionManager().shutdown();

} catch (MalformedURLException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

}

Output server

Output from Server ....

Bonita BPM Portal

Welcome to Bonita BPM Portal

Login form

Unable to log in. Please check your username and password.

bonita.2014-01-15.log

gen 15, 2014 9:48:48 AM org.bonitasoft.console.common.server.login.datastore.LoginDatastore login
Grave: Error while logging in on the engine API.

---

Of course user myuser : mypassword is in db of the engine.

What's wrong?

Thanks in advance

Comments

Submitted by ttoine on Mon, 01/20/2014 - 10:29

did you use the technical account (install / install) to create the first admin users ?

Submitted by box on Mon, 01/20/2014 - 10:54

Yes I did

Submitted by ttoine on Mon, 01/20/2014 - 11:08

If I understand, you try to log in through the API, via a third party application? can you log in with Bonita BPM Portal, to check if the problem is with your script, or with Bonita.

Submitted by box on Mon, 01/20/2014 - 12:00

Unfortunately, I can login to the portal with the same credentials. The problem is my script. If I understand the portal is "like" third part application (because use REST API). Do you know where I can find the code?

1 answer

Notifications