public function authenticate(\Moltin\SDK\AuthenticateInterface $auth, $args = array()) { // Skip active auth or refresh current if ($this->expires > 0 and $this->expires > time()) { return true; } elseif ($this->expires > 0 and $this->expires < time()) { return $this->refresh($args); } // Perform authentication $auth->authenticate($args, $this); // Store $this->_storeToken($auth); return $this->token === null ? false : true; }
public function authenticate(\Moltin\SDK\AuthenticateInterface $auth, $args = array()) { // Skip active auth or refresh current if ($this->expires > 0 and $this->expires > time()) { return true; } else { if ($this->expires > 0 and $this->expires < time() and $this->refresh !== null) { return $this->refresh(['client_id' => $args['client_id'], 'client_secret' => $args['client_secret'], 'token' => $this->token, 'refresh_token' => $this->refresh, 'expires' => $this->expires]); } } // Perform authentication $auth->authenticate($args, $this); // Store $this->_storeToken($auth); return $this->token === null ? false : true; }