Phpmailer和oauth

I am trying to send emails using gmail smtp server with oauth. I have received refresh token, there everything was ok, but as I couldn't find any example for sending email with oauth, seems like I am missing something in mail sending script. My code is the following:

$phpmailer = new PHPMailerOAuth();
$phpmailer->IsSMTP();
$phpmailer->SMTPDebug  = 2;
$phpmailer->Host       = "ssl://smtp.gmail.com";
$phpmailer->SMTPAuth   = true;
$phpmailer->SMTPSecure = 'ssl';
$mail->AuthType = 'XOAUTH2';
$phpmailer->Port       = 465;

$phpmailer->oauthClientId = "***";
$phpmailer->oauthClientSecret = "***";
$phpmailer->oauthRefreshToken = "***";
$phpmailer->oauthUserEmail="***";

Just found the solution. In case anyone needs, my problem was that I haven't included vendor/autoload.php file, which composer created:

  require_once dirname(__FILE__).'/PHPMailerAutoload.php';