Hey @phamdacloc,
You are welcome to modify the code to do whatever you would like. By simply modified the default access_lifetime in the plugin manually.
OAuth 2.0 is a set in stone draft and does not permit that access tokens to be valid for never. With this said, it is a draft and to each their own. If you change the lifetime to something like 999999999, the token will not last a forever but they will last a very long time.
This is fabulous. I saw there are two places where access_lifetime was set (AccessToken.php and Server.php). I went ahead and set access_lifetime in AccessToken.php to a very large number 999999999. Is this the only place I need to make the change?
Hi Justin,
I set access_lifetime to 999999999 in both AccessToken.php and Server.php but my token still expires after an hour. Can you think of any other places I must make changes to?
Thanks
You should only have to change the value in class-wo-api.php.
Line 38
'refresh_token_lifetime' => $o['refresh_token_lifetime'] == '' ? 86400 : $o['refresh_token_lifetime'],
Would change to:
'refresh_token_lifetime' => 99999999,
Humm, I think we’re missing some other variables because I changed the above to 'refresh_token_lifetime' => 99999999
inside class-wo-api.php and my token still expires.
Hi Loc,
Are you running the latest version (3.1.9)?
Hey Justin,
No, I was at 3.1.8 but let me upgrade to 3.1.9 and run for a few hours to see if my token expires. I’ll keep you posted.
Thanks
Hi Justin,
I upgraded to 3.1.9 and see no difference on the expiration of access_token. I had to login again after it expire to continue using my application.
Jason, Can you think of any other places where token expiration may get set? refresh_token_lifetime
doesn’t seem to work when I tested.
Thanks.
Hi Loc,
My apologies. I am going back though our conversation and I think I may have given you the wrong information. I am not sure how it slipped passed me but I gave you the refresh_token instead of the access_token.
You would change
'access_lifetime' => $o['access_token_lifetime'] == '' ? 3600 : $o['access_token_lifetime'],
to
'access_lifetime' => 9999999,
Keep in mind, by modifying the code manually, all will be lost on the next update. We also not not technically support modified code but I am always here for advice.
Thanks
Thank you Justin. Your support is very much appreciated.
Awesome and you are very Welcome