Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderator: amosbatto

Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#824046
I am trying to login with the following way from inside a plugin class.pmFunctions.php file
1- I am getting the user uid from the session.
2- using user uid fetching all user info from the database.
3- fetching username, password in md5 form.
3- log in with curl to get the access token.


The problem is I want to log in using hashed password and it does not seem to work for me I took the code from a colleague according to him it works just fine on his server, but when I use normal password string it works just fine
Code: Select all
  

$pstParams = array(
            "grant_type"    => "password",
            "scope"         => "*",
            "client_id"     => "clientId",
            "client_secret" => "clientSecret",
            "username"      => $username,
            "password"      => "md5:".$hashedPassword
        );

        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        curl_setopt($ch, CURLOPT_POST,1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $pstParams);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);

        $response = json_decode($response);
        var_dump($response);

    }
This is the response I am getting
Code: Select all
stdClass Object
(
    [error] => invalid_grant
    [error_description] => Invalid username and password combination
)

How i can solve this problem to login with out asking for password just to use the hashed password from thE database?
#824051
You can login with a hashed password when using web services. See:
https://wiki.processmaker.com/3.0/Proce ... e_Database

However, oAuth2 (which is the login method used by ProcessMaker's REST API) doesn't support login with a hashed password, so you will need to know the user's real password.

If you want to obtain the access token to make REST calls in your plugin, see:
https://www.pmusers.com/index.php/Plugin_development

Hi Amosbatto. I apologise, I have been away for w[…]

Export grid to excel or csv

I want to export a grid to any kind of excel or cs[…]

Custom inbox columns

Can we add a variable from a process as a column w[…]

Hi, I'm programming a case in which a logged-in us[…]