mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 19:48:49 +02:00
N°3169 - Add feature to connect Gsuite mail box with OAuth
N°2504 - Add feature to connect Office mail box with OAuth2 for Microsoft Graph N°5102 - Allow to send emails (eg. notifications) using GSuite SMTP and OAuth
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace Combodo\iTop\Core\Authentication\Client\OAuth;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Panel\Panel;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Panel\PanelUIBlockFactory;
|
||||
use Dict;
|
||||
use League\OAuth2\Client\Token\AccessToken;
|
||||
|
||||
class OAuthClientResultDisplayConf implements IOAuthClientResultDisplay
|
||||
{
|
||||
public static function GetResultDisplayBlock()
|
||||
{
|
||||
$oConfResultPanel = new Panel(Dict::S('UI:OAuth:Wizard:ResultConf:Panel:Title'), [],Panel::DEFAULT_COLOR_SCHEME, 'ibo-oauth-wizard--conf--panel');
|
||||
$oConfResultPanel->AddCSSClass('ibo-oauth-wizard--result--panel');
|
||||
$oConfResultPanel->SetIsCollapsible(true);
|
||||
$oConfResultPanel->AddHtml('<p>'.Dict::S('UI:OAuthEmailSynchro:Wizard:ResultConf:Panel:Description').'</p>');
|
||||
$oConfResultPanel->AddHtml('<pre><code id="ibo-oauth-wizard--conf--result"></code></pre>');
|
||||
return $oConfResultPanel;
|
||||
}
|
||||
|
||||
public static function GetResultDisplayScript($sClientId, $sClientSecret, $sVendor, AccessToken $oAccessToken)
|
||||
{
|
||||
$sAccessToken = $oAccessToken->getToken();
|
||||
$sRefreshToken = $oAccessToken->getRefreshToken();
|
||||
$sConf = <<<EOF
|
||||
'email_transport' => 'SMTP_OAuth',
|
||||
'email_transport_smtp.oauth.provider' => '$sVendor',
|
||||
'email_transport_smtp.oauth.client_id' => '$sClientId',
|
||||
'email_transport_smtp.oauth.client_secret' => '$sClientSecret',
|
||||
'email_transport_smtp.oauth.access_token' => '$sAccessToken',
|
||||
'email_transport_smtp.oauth.refresh_token' => '$sRefreshToken',
|
||||
EOF;
|
||||
$sConf = json_encode($sConf);
|
||||
|
||||
return <<<JS
|
||||
$('#ibo-oauth-wizard--conf--panel .ibo-panel--collapsible-toggler').click();
|
||||
$('#ibo-oauth-wizard--conf--result').text($sConf);
|
||||
JS;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user