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:
@@ -2,44 +2,34 @@
|
||||
|
||||
namespace Combodo\iTop\Core\Authentication\Client\OAuth;
|
||||
|
||||
use League\OAuth2\Client\Token\AccessToken;
|
||||
use TheNetworg\OAuth2\Client\Provider\Azure;
|
||||
|
||||
class OAuthClientProviderAzure extends OAuthClientProviderAbstract
|
||||
{
|
||||
/** @var string */
|
||||
static protected $sVendorName = 'Azure';
|
||||
/** @var array */
|
||||
static protected $sVendorColors = ['#0766b7', '#0d396b', '#2893df', '#3ccbf4'];
|
||||
/** @var string */
|
||||
static protected $sVendorIcon = '../images/icons/icons8-azure.svg';
|
||||
static protected $sRequiredSMTPScope = 'https://outlook.office.com/SMTP.Send offline_access';
|
||||
static protected $sRequiredIMAPScope = 'https://outlook.office.com/IMAP.AccessAsUser.All offline_access';
|
||||
static protected $sRequiredPOPScope = 'https://outlook.office.com/POP.AccessAsUser.All offline access';
|
||||
// /** @var string */
|
||||
// static protected $sVendorName = 'Azure';
|
||||
// /** @var array */
|
||||
// static protected $sVendorColors = ['#0766b7', '#0d396b', '#2893df', '#3ccbf4'];
|
||||
// /** @var string */
|
||||
// static protected $sVendorIcon = '../images/icons/icons8-azure.svg';
|
||||
// static protected $sRequiredSMTPScope = 'https://outlook.office.com/SMTP.Send offline_access';
|
||||
// static protected $sRequiredIMAPScope = 'https://outlook.office.com/IMAP.AccessAsUser.All offline_access';
|
||||
// static protected $sRequiredPOPScope = 'https://outlook.office.com/POP.AccessAsUser.All offline access';
|
||||
|
||||
/** @var \League\OAuth2\Client\Token\AccessToken */
|
||||
protected $oAccessToken;
|
||||
|
||||
public function __construct($aVendorProvider, array $collaborators = [], array $aAccessTokenParams = [])
|
||||
public function __construct($oOAuthClient, array $collaborators = [])
|
||||
{
|
||||
$this->oVendorProvider = new Azure(array_merge([
|
||||
parent::__construct($oOAuthClient);
|
||||
|
||||
$aOptions = [
|
||||
'prompt' => 'consent',
|
||||
'scope' => 'offline_access',
|
||||
'defaultEndPointVersion' => Azure::ENDPOINT_VERSION_2_0,
|
||||
],
|
||||
$aVendorProvider), $collaborators);
|
||||
'clientId' => $oOAuthClient->Get('client_id'),
|
||||
'clientSecret' => $oOAuthClient->Get('client_secret'),
|
||||
'redirectUri' => $oOAuthClient->Get('redirect_url'),
|
||||
];
|
||||
|
||||
if (!empty($aAccessTokenParams)) {
|
||||
$this->oAccessToken = new AccessToken([
|
||||
"access_token" => $aAccessTokenParams["access_token"],
|
||||
"expires_in" => -1,
|
||||
"refresh_token" => $aAccessTokenParams["refresh_token"],
|
||||
"token_type" => "Bearer",
|
||||
]);
|
||||
}
|
||||
|
||||
if (isset($aVendorProvider['scope'])) {
|
||||
$this->SetScope($aVendorProvider['scope']);
|
||||
}
|
||||
$this->oVendorProvider = new Azure($aOptions, $collaborators);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user