Screenshot New Years Sale Get the "ALL ACCESS PASS" and Save $349. Unlimited Licenses.
Show All Access Pass

Never Expiring Access Token

Published: April 14, 2019 | Updated: June 11th, 2020
  1. Home
  2. Docs
  3. How To
  4. Never Expiring Access Token

If should be noted that setting an access token without an expiration is not considered “Best Practice”.

The core of WP OAuth Server is built using standard practice and stores all access tokens in the database without open to direct modification. If you desire to assign no expiration to access tokens, you can use a filter to modify the expiration time during the query.

Place the following code in the theme’s functions.php file

add_filter( 'wo_get_access_token_expires_return','wo_modify_expires_token' ); 
function wo_modify_expires_token( $expires ) { 
    return strtotime( '+99 years', $expires ); 
}
Icon