Hubspot_Helpers::maybe_refresh_token( mixed $tokens )

maybe_refresh_token


Parameters Parameters

$tokens

(Required)


Top ↑

Return Return

(void)


Source Source

File: src/integrations/hubspot/helpers/hubspot-helpers.php

	public function maybe_refresh_token( $tokens ) {

		$expiration_timestamp = $tokens['stored_at'] + $tokens['expires_in'];

		// Check if token will expire in the next minute
		if ( time() > $expiration_timestamp - MINUTE_IN_SECONDS ) {
			// Token is expired or will expire soon, refresh it
			return $this->api_refresh_token( $tokens );
		}

		return $tokens;
	}