Share ideas, ask questions, and get feedback about developing for ProcessMaker

Moderators: ArturoRobles, ArturoRobles

Forum rules: Please post new questions under "Developing processes & programming" for ProcessMaker 2 or 3.
By gresham
#785925
Hi

I've created an external app and using the oauth2 i configured the client and secret codes and it works perfectly. The app basically uses the REST endpoint for the cases and creates a calendar agenda of tasks.

I'd like to now convert this into a plugin so that its accessible from within PM as a menu. I know how to create the basic plugin files using gulliver but now i'm not sure if I need to request the user to re-login using my app and get the access token and then consume the REST endpoint, or can I simply call the endpoint and it would work ?

Any advice or samples can I could have a look at ?
#785930
In the database, there is a table which links the oAuth2 access token with a PHP login session in ProcessMaker. I can't remember the name of the table off the top of my head and I don't have PM installed on my computer to check it. Anyway, you can do a database search for the ID of the current logged-in user and the most recent record to get the access token.

The code would be something like:
Code: Select all
$userId = $_SESSION['USER_LOGGED'];
$query = "SELECT * FROM ???OAUTH_TABLE??? WHERE USR_UID='$userId' ORDER BY ???DATE_FIELD??? DESC";
$result = executeQuery($query);
$accessToken = $result[1]['???TOKEN_FIELD???'];
If you can't find the table in the database, I will look it up for you on Monday.
By gresham
#785935
amosbatto wrote:
The code would be something like:
Code: Select all
$userId = $_SESSION['USER_LOGGED'];
$query = "SELECT * FROM ???OAUTH_TABLE??? WHERE USR_UID='$userId' ORDER BY ???DATE_FIELD??? DESC";
$result = executeQuery($query);
$accessToken = $result[1]['???TOKEN_FIELD???'];
Code: Select all
SELECT * FROM oauth_access_tokens WHERE USER_ID='$userId' ORDER BY expires DESC
Got it ! thats the correct field names and table.
amosbatto, thank you !
By chendg
#785973
hi,
you said you have created an external app and using the oauth2 i configured the client and secret codes and it works perfectly.But when i tried, it gaved me a 400 code.
Could you give me some advice?
By gresham
#785975
chendg wrote:hi,
you said you have created an external app and using the oauth2 i configured the client and secret codes and it works perfectly.But when i tried, it gaved me a 400 code.
Could you give me some advice?
Normally, that means that the json is badly formatted or does not conform to the standard format. Are you using the REST service to get data or post ? if post then i suggest you look at the format of your JSON object. I'm not an expert on this and I could be wrong, but that would be my starting point.
By chendg
#785986
I just try to achieve the example of rest API in chapter "Get the ProcessMaker Cases List in an external application",but it returned "{"error":"invalid_grant","error_description":"The authorization code has expired"}400".I think it should get a new access_token, but don't know wthat todo.

Maybe try increasing your thread stack size? Seems[…]

I use PM 3.4. Android push works while IOS push do[…]

[quote=ziadeh post_id=823031 time=1550759948 user_[…]

I have to support reports in processmaker 3.4. A s[…]