-
Notifications
You must be signed in to change notification settings - Fork 2
/
callback.php
27 lines (20 loc) · 750 Bytes
/
callback.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
use Mautic\Auth\ApiAuth;
require_once 'vendor/autoload.php';
require_once('shared.php');
$config = load_settings();
$_SESSION['oauth']['state'] = $config['mautic']['state'];
$initAuth = new ApiAuth();
$auth = $initAuth->newAuth($config['mautic']);
$auth->validateAccessToken();
if ($auth->accessTokenUpdated()) {
$accessTokenData = $auth->getAccessTokenData();
$config['mautic'] = array_merge($config['mautic'],
[
'accessToken' => $accessTokenData['access_token'],
'accessTokenExpires' => $accessTokenData['expires'],
'refreshToken' => $accessTokenData['refresh_token'],
]);
echo 'Access token acquired, you can close this window and go back to the terminal';
save_settings($config);
}