mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
N°5102 - Allow to send emails using GSuite SMTP and OAuth - Rework
This commit is contained in:
@@ -3,38 +3,33 @@
|
||||
namespace Combodo\iTop\Core\Authentication\Client\OAuth;
|
||||
|
||||
use League\OAuth2\Client\Provider\Google;
|
||||
use League\OAuth2\Client\Token\AccessToken;
|
||||
|
||||
class OAuthClientProviderGoogle extends OAuthClientProviderAbstract
|
||||
{
|
||||
/** @var string */
|
||||
static protected $sVendorName = 'Google';
|
||||
/** @var array */
|
||||
static protected $sVendorColors = ['#DB4437', '#F4B400', '#0F9D58', '#4285F4'];
|
||||
/** @var string */
|
||||
static protected $sVendorIcon = '../images/icons/icons8-google.svg';
|
||||
// /** @var string */
|
||||
// static protected $sVendorName = 'Google';
|
||||
// /** @var array */
|
||||
// static protected $sVendorColors = ['#DB4437', '#F4B400', '#0F9D58', '#4285F4'];
|
||||
// /** @var string */
|
||||
// static protected $sVendorIcon = '../images/icons/icons8-google.svg';
|
||||
//
|
||||
// static protected $sRequiredSMTPScope = 'https://mail.google.com/';
|
||||
// static protected $sRequiredIMAPScope = 'https://mail.google.com/';
|
||||
// static protected $sRequiredPOPScope = 'https://mail.google.com/';
|
||||
|
||||
/** @var \League\OAuth2\Client\Token\AccessToken */
|
||||
protected $oAccessToken;
|
||||
static protected $sRequiredSMTPScope = 'https://mail.google.com/';
|
||||
static protected $sRequiredIMAPScope = 'https://mail.google.com/';
|
||||
static protected $sRequiredPOPScope = 'https://mail.google.com/';
|
||||
|
||||
public function __construct($aVendorProvider, array $collaborators = [], array $aAccessTokenParams = [])
|
||||
public function __construct($oOAuthClient, array $collaborators = [])
|
||||
{
|
||||
$this->oVendorProvider = new Google(array_merge(['prompt' => 'consent', 'accessType' => 'offline'], $aVendorProvider), $collaborators);
|
||||
parent::__construct($oOAuthClient);
|
||||
$aOptions = [
|
||||
'prompt' => 'consent',
|
||||
'accessType' => 'offline',
|
||||
'clientId' => $oOAuthClient->Get('client_id'),
|
||||
'clientSecret' => $oOAuthClient->Get('client_secret'),
|
||||
'redirectUri' => $oOAuthClient->Get('redirect_url'),
|
||||
'scope' => $oOAuthClient->GetScope(),
|
||||
|
||||
if (!empty($aAccessTokenParams)) {
|
||||
$this->oAccessToken = new AccessToken([
|
||||
"access_token" => $aAccessTokenParams["access_token"],
|
||||
"expires_in" => -1,
|
||||
"refresh_token" => $aAccessTokenParams["refresh_token"],
|
||||
"token_type" => "Bearer",
|
||||
]);
|
||||
}
|
||||
];
|
||||
$this->oVendorProvider = new Google($aOptions, $collaborators);
|
||||
|
||||
if (isset($aVendorProvider['scope'])) {
|
||||
$this->SetScope($aVendorProvider['scope']);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user