Skip to content

Commit

Permalink
Update gmail.php
Browse files Browse the repository at this point in the history
  • Loading branch information
lianglee authored Jan 1, 2023
1 parent 1a4e000 commit b3d55af
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions actions/admin/settings/gmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,25 @@
* @license Open Source Social Network License (OSSN LICENSE) http://www.opensource-socialnetwork.org/licence
* @link https://www.opensource-socialnetwork.org/
*/
require_once(__SMTP__ . 'vendor/google/vendor/autoload.php');
require_once __SMTP__ . 'vendor/google/vendor/autoload.php';
use League\OAuth2\Client\Provider\Google;

$smtp = new OssnComponents;
$smtp = new OssnComponents();
$settings = $smtp->getSettings('SMTP');

$provider = new Google([
'clientId' => $settings->clientId,
'clientSecret' => $settings->clientSecret,
'redirectUri' => ossn_site_url('smtp_oauth/google'),
'accessType' => 'offline'
]);
$options = [
'scope' => [
'https://mail.google.com/'
]
];
$authUrl = $provider->getAuthorizationUrl($options);
$provider = new Google(array(
'clientId' => $settings->clientId,
'clientSecret' => $settings->clientSecret,
'redirectUri' => ossn_site_url('smtp_oauth/google'),
'accessType' => 'offline',
));
$options = array(
'prompt' => 'consent',
'scope' => array(
'https://mail.google.com/',
),
);
$authUrl = $provider->getAuthorizationUrl($options);
$_SESSION['oauth2state'] = $provider->getState();
header("Location: {$authUrl}");
exit;
exit();

0 comments on commit b3d55af

Please sign in to comment.