Never Expiring Access Token | WordPress OAuth Codex

Never Expiring Access Token

Documentation under "How To" for WP OAuth Server


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 );
}