diff options
author | emkael <emkael@tlen.pl> | 2016-10-31 22:09:16 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-10-31 22:09:16 +0100 |
commit | 6181693f1d4b021da8a699c19f5323a17ffab1de (patch) | |
tree | ef5002fb9846c8d8405535d7afbf97ed19dd3371 /lib/phpmailer/class.phpmaileroauthgoogle.php | |
parent | 7271d04e72aca36497f5cc04c5083c7c835cc6ca (diff) |
* PHPMailer library
Diffstat (limited to 'lib/phpmailer/class.phpmaileroauthgoogle.php')
-rw-r--r-- | lib/phpmailer/class.phpmaileroauthgoogle.php | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/lib/phpmailer/class.phpmaileroauthgoogle.php b/lib/phpmailer/class.phpmaileroauthgoogle.php new file mode 100644 index 0000000..71c9bd3 --- /dev/null +++ b/lib/phpmailer/class.phpmaileroauthgoogle.php @@ -0,0 +1,77 @@ +<?php +/** + * PHPMailer - PHP email creation and transport class. + * PHP Version 5.4 + * @package PHPMailer + * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project + * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk> + * @author Jim Jagielski (jimjag) <jimjag@gmail.com> + * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net> + * @author Brent R. Matzelle (original founder) + * @copyright 2012 - 2014 Marcus Bointon + * @copyright 2010 - 2012 Jim Jagielski + * @copyright 2004 - 2009 Andy Prevost + * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License + * @note This program is distributed in the hope that it will be useful - WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + */ + +/** + * PHPMailerOAuthGoogle - Wrapper for League OAuth2 Google provider. + * @package PHPMailer + * @author @sherryl4george + * @author Marcus Bointon (@Synchro) <phpmailer@synchromedia.co.uk> + * @link https://github.com/thephpleague/oauth2-client + */ +class PHPMailerOAuthGoogle +{ + private $oauthUserEmail = ''; + private $oauthRefreshToken = ''; + private $oauthClientId = ''; + private $oauthClientSecret = ''; + + /** + * @param string $UserEmail + * @param string $ClientSecret + * @param string $ClientId + * @param string $RefreshToken + */ + public function __construct( + $UserEmail, + $ClientSecret, + $ClientId, + $RefreshToken + ) { + $this->oauthClientId = $ClientId; + $this->oauthClientSecret = $ClientSecret; + $this->oauthRefreshToken = $RefreshToken; + $this->oauthUserEmail = $UserEmail; + } + + private function getProvider() + { + return new League\OAuth2\Client\Provider\Google([ + 'clientId' => $this->oauthClientId, + 'clientSecret' => $this->oauthClientSecret + ]); + } + + private function getGrant() + { + return new \League\OAuth2\Client\Grant\RefreshToken(); + } + + private function getToken() + { + $provider = $this->getProvider(); + $grant = $this->getGrant(); + return $provider->getAccessToken($grant, ['refresh_token' => $this->oauthRefreshToken]); + } + + public function getOauth64() + { + $token = $this->getToken(); + return base64_encode("user=" . $this->oauthUserEmail . "\001auth=Bearer " . $token . "\001\001"); + } +} |