Page 1 of 1

Can we get an access_token without using username and password

Posted: Tue Aug 13, 2019 12:06 am
by jemiris
Hi,

Can we get the access_token without passing username and password https://wiki.processmaker.com/3.1/OAuth ... o_use_REST ?

Re: Can we get an access_token without using username and password

Posted: Tue Aug 13, 2019 9:44 pm
by amosbatto
If you want to use the access_token for the existing login session:
If you are inside a Dynaform, see:
https://wiki.processmaker.com/3.1/JavaS ... ing_jQuery

If you are in a trigger or a plugin, then see:
https://www.pmusers.com/index.php/Plugin_development

Re: Can we get an access_token without using username and password

Posted: Tue Aug 13, 2019 11:52 pm
by jemiris
As of my understanding for the first time I need to use username and password to generate the access token for the next time, I can use the refresh token to get the access token again. Is that correct?

And I have read in the documentation that refresh token doesn't expire until it's used to get an access token. The access token expires in 86400 (that means 24hours). The login session time expiry in 24mintues (it can be extended by changing php.ini file -> https://wiki.processmaker.com/index.php ... ssion_Time)

Re: Can we get an access_token without using username and password

Posted: Wed Aug 14, 2019 11:17 pm
by amosbatto
jemiris wrote: Tue Aug 13, 2019 11:52 pm As of my understanding for the first time I need to use username and password to generate the access token for the next time, I can use the refresh token to get the access token again. Is that correct?
Correct.
If you are executing your code inside a Dynaform or inside a trigger or plugin, then you can use the existing login session which is created when the user logs into ProcessMaker, as shown in the examples that I gave you in the previous post. If that login session has expired, then you can either redirect to the login page with this PHP code:
Code: Select all
if (!isset($_SESSION['USER_LOGGED'])) {
	header("Location: ../login/login");
}
or you can use the refresh token. I never use refresh tokens, because it easier to make the user login again.
jemiris wrote:And I have read in the documentation that refresh token doesn't expire until it's used to get an access token. The access token expires in 86400 (that means 24hours). The login session time expiry in 24mintues (it can be extended by changing php.ini file -> https://wiki.processmaker.com/index.php ... ssion_Time)
The access_token expires after 24 minutes by default and the refresh_token expires after 24 hours (or when it is used to get a new access_token or when the user logs in again). I have never tested the expiration of a refresh_token, so I might be incorrect, so you will have to test it.

Re: Can we get an access_token without using username and password

Posted: Sat Aug 17, 2019 7:58 am
by jemiris
Thank you i will be testing that

Re: Can we get an access_token without using username and password

Posted: Mon Oct 21, 2019 6:22 am
by vktRus
How to do it in another version PM 2.8?

Re: Can we get an access_token without using username and password

Posted: Mon Oct 21, 2019 11:45 pm
by jemiris
I have done using session id. I have used version 3.0 version